Re: Newbie math trouble [message #62627] |
Mon, 29 September 2008 21:36 |
Gaurav
Messages: 50 Registered: January 2007
|
Member |
|
|
Thank you very much. I was also able to locate an old thread on the
newsgroup pointing me to do the same.
Thank you for your consideration.
Gaurav
|
|
|
Re: Newbie math trouble [message #62654 is a reply to message #62627] |
Mon, 29 September 2008 03:51  |
Wox
Messages: 184 Registered: August 2006
|
Senior Member |
|
|
On Mon, 29 Sep 2008 00:39:10 -0700 (PDT), Gaurav
<selfishgaurav@gmail.com> wrote:
> 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
http://www.dfanning.com/code_tips/comparearray.html
|
|
|