Newbie math trouble [message #62656] |
Mon, 29 September 2008 00:39 |
Gaurav
Messages: 50 Registered: January 2007
|
Member |
|
|
Dear all,
I am having trouble comparing floating point numbers. I seem to have
seen it solved somewhere in IDL help but I am not able to locate it
today. The following simple snippet illustrates the trouble:
;############################################
bottom_value = 327.3 ; usually a user input
interval = 0.3
start_value = ceil(bottom_value/interval) * interval
;start value will contain the smallest number > bottom_value that is
divisible by interval
print, bottom_value, start_value
if bottom_value ne start_value then print, 'All is not well'
;############################################
this code gives me the output:
327.300, 327.300
All is not well
Clearly all is not well. I believe IDL is trying to compare Double
values instead of Float values. How do I overcome this. Any insight
would be highly appreciated.
Gaurav
|
|
|