comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » WHERE command returning -1 even if matching is there
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
WHERE command returning -1 even if matching is there [message #93353] Wed, 22 June 2016 08:50 Go to next message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
Hello All,

I have a long float array say b_arr.
and I know it has a value 0.999254 at position 4556th in b_arr
but when I am doing:

i=where( b_arr EQ 0.999254)
print,i
-1

It should return i=4556. isn't??
How come is this possible any help please?
Re: WHERE command returning -1 even if matching is there [message #93354 is a reply to message #93353] Wed, 22 June 2016 09:02 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Wednesday, June 22, 2016 at 4:50:22 PM UTC+1, Sapna Mishra wrote:
> Hello All,
>
> I have a long float array say b_arr.
> and I know it has a value 0.999254 at position 4556th in b_arr
> but when I am doing:
>
> i=where( b_arr EQ 0.999254)
> print,i
> -1
>
> It should return i=4556. isn't??
> How come is this possible any help please?

Try printing:
print, b_arr[4556]-0.999254
print, b_arr[4556] eq 0.999254

What do you get?

Cheers,
Helder
Re: WHERE command returning -1 even if matching is there [message #93355 is a reply to message #93354] Wed, 22 June 2016 09:14 Go to previous messageGo to next message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
On Wednesday, June 22, 2016 at 9:32:13 PM UTC+5:30, Helder wrote:
> On Wednesday, June 22, 2016 at 4:50:22 PM UTC+1, Sapna Mishra wrote:
>> Hello All,
>>
>> I have a long float array say b_arr.
>> and I know it has a value 0.999254 at position 4556th in b_arr
>> but when I am doing:
>>
>> i=where( b_arr EQ 0.999254)
>> print,i
>> -1
>>
>> It should return i=4556. isn't??
>> How come is this possible any help please?
>
> Try printing:
> print, b_arr[4556]-0.999254
> print, b_arr[4556] eq 0.999254
>
> What do you get?
>
> Cheers,
> Helder

I am getting
3.57628e-07
0

I don't know what is wrong they both are the same numbers
Re: WHERE command returning -1 even if matching is there [message #93356 is a reply to message #93355] Wed, 22 June 2016 10:21 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Maybe the sky is falling
http://www.idlcoyote.com/math_tips/sky_is_falling.html

You might also use the following function for comparing floating point numbers
https://www.idlcoyote.com/programs/floats_equal.pro


On Wednesday, June 22, 2016 at 12:14:14 PM UTC-4, Sapna Mishra wrote:
> On Wednesday, June 22, 2016 at 9:32:13 PM UTC+5:30, Helder wrote:
>> On Wednesday, June 22, 2016 at 4:50:22 PM UTC+1, Sapna Mishra wrote:
>>> Hello All,
>>>
>>> I have a long float array say b_arr.
>>> and I know it has a value 0.999254 at position 4556th in b_arr
>>> but when I am doing:
>>>
>>> i=where( b_arr EQ 0.999254)
>>> print,i
>>> -1
>>>
>>> It should return i=4556. isn't??
>>> How come is this possible any help please?
>>
>> Try printing:
>> print, b_arr[4556]-0.999254
>> print, b_arr[4556] eq 0.999254
>>
>> What do you get?
>>
>> Cheers,
>> Helder
>
> I am getting
> 3.57628e-07
> 0
>
> I don't know what is wrong they both are the same numbers
Re: WHERE command returning -1 even if matching is there [message #93357 is a reply to message #93355] Wed, 22 June 2016 10:24 Go to previous message
rawahranger is currently offline  rawahranger
Messages: 14
Registered: March 2016
Junior Member
Sapna Mishra writes:

> I am getting
> 3.57628e-07
> 0
>
> I don't know what is wrong they both are the same numbers

I have a feeling this Sky is Falling article will remain my lasting legacy well into the next century! ;-)

http://www.idlcoyote.com/math_tips/sky_is_falling.html

Cheers,

David
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: NaN doesn't work!
Next Topic: Let's get it right - Plotting ans Saving

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 07:14:34 PDT 2025

Total time taken to generate the page: 0.00524 seconds