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

Home » Public Forums » archive » IDL not interpreting numbers correctly?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL not interpreting numbers correctly? [message #77421 is a reply to message #77367] Wed, 31 August 2011 05:51 Go to previous message
rogass is currently offline  rogass
Messages: 200
Registered: April 2008
Senior Member
On 27 Aug., 02:37, Ashley Berg <ashley.b...@gmail.com> wrote:
> I'm having a strange problem with IDL.  I have an array of numbers
> that are supposed to all add up to 100.  So to check, I say:
>
> bad = where(array gt 100. or array lt 100.)
>
> and it says it finds 4 numbers that meet this criteria. However, when
> I say:
>
> print, array(bad)
>
> the numbers are all 100.000!  So for some reason IDL says these
> numbers are greater than or less than 100 when actually they are equal
> to 100.  Has anyone else ever had a problem like this?

Hi,
we have all the same problem :)

Maybe you can use this:

function cr_c,a,b,type,prec=prec
szt = size(a,/type)+size(b,/type)
small = (szt eq 10 or szt eq 14 or szt eq 18)? $
(machar(/double)).eps : (machar()).eps
prec = ~n_elements(prec)? $
make_array(1,type=size(small,/type),value=1) : $
make_array(1,type=size(small,/type),value=prec)
small *= prec
type = ~n_elements(type)? 'eq' : type
case type of
'eq' : return, (abs(a-b) lt small)[0]
'ne' : return, (abs(a-b) gt small)[0]
'lt' : return, ((b-a) gt small)[0]
'le' : return, ((b-a) ge small)[0]
'gt' : return, ((a-b) gt small)[0]
'ge' : return, ((a-b) ge small)[0]
endcase
end

IDL> help,(4.70*100.) eq 470.0
<Expression> BYTE = 0
IDL> help,cr_c(4.70*100.,470.0,'eq')
<Expression> BYTE = 0
IDL> help,cr_c(4.70*100.,470.0,'eq',prec=1000)
<Expression> BYTE = 1

Cheers

CR
[Message index]
 
Read Message
Read Message
Previous Topic: Finding a large number of files - ls vs file_search?
Next Topic: cgis routines

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

Current Time: Sat Oct 11 14:59:31 PDT 2025

Total time taken to generate the page: 1.52226 seconds