Re: Strange return from where function [message #67973] |
Wed, 16 September 2009 03:59 |
Wout De Nolf
Messages: 194 Registered: October 2008
|
Senior Member |
|
|
On Tue, 15 Sep 2009 22:19:31 -0700 (PDT), David
<byrne.david@gmail.com> wrote:
> On Sep 16, 3:14�pm, David <byrne.da...@gmail.com> wrote:
>> Hey guys not sure what is going on here.
>>
>> I have an array with particle IDs to track particles. I want to search
>> for the particles in the array by thier particle ID.
>>
>> Simple where call but its being strange. This is what i get
>>
>> IDL> print,index
>> � � � 1.00000
>> IDL> wh_track_full=where(tracks[0,*] eq index)
>> IDL> print, wh_track_full
>> � � � � � �0
>> IDL> wh_track_full=where(tracks[0,*] eq 1.0000)
>> IDL> print, wh_track_full
>> � � � � � �0 � � � � � 1
>>
>> So you see it finds all the elements with an ID of 1.000 if i type in
>> the actual value. But when i assign it to a variable I just pick up
>> the first element and not the second.
>>
>> I've never come across this before,
>>
>> any ideas?
>>
>> Regards
>> David
>
> Actually i found the problem. It was that index was Float = array[1] I
> had to use wh_track_full=where(tracks[0,*] eq index[0]) for it to
> work.
>
> -David
Also remember sky-is-falling issues: a real or rational number is only
stored exactly (in floating point representation) when it can be
written as f=x.2^y
All other numbers are rounded to the closest x.2^y so everything
between x.2^y and (x+1).2^y is stored as one of these two numbers.
So for example:
IDL> x=8388608
IDL> y=-23
IDL> print,x*2.^y,format='(F100.50)'
1.00000000000000000000000000000000000000000000000000
IDL> print,(x+1)*2.^y,format='(F100.50)'
1.00000011920928960000000000000000000000000000000000
IDL> print,1. eq 1.00000001
1
|
|
|
Re: Strange return from where function [message #67976 is a reply to message #67973] |
Tue, 15 September 2009 22:19  |
byrne.david
Messages: 3 Registered: November 2007
|
Junior Member |
|
|
On Sep 16, 3:14 pm, David <byrne.da...@gmail.com> wrote:
> Hey guys not sure what is going on here.
>
> I have an array with particle IDs to track particles. I want to search
> for the particles in the array by thier particle ID.
>
> Simple where call but its being strange. This is what i get
>
> IDL> print,index
> 1.00000
> IDL> wh_track_full=where(tracks[0,*] eq index)
> IDL> print, wh_track_full
> 0
> IDL> wh_track_full=where(tracks[0,*] eq 1.0000)
> IDL> print, wh_track_full
> 0 1
>
> So you see it finds all the elements with an ID of 1.000 if i type in
> the actual value. But when i assign it to a variable I just pick up
> the first element and not the second.
>
> I've never come across this before,
>
> any ideas?
>
> Regards
> David
Actually i found the problem. It was that index was Float = array[1] I
had to use wh_track_full=where(tracks[0,*] eq index[0]) for it to
work.
-David
|
|
|