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

Home » Public Forums » archive » Re: round not behaving
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: round not behaving [message #46000] Thu, 27 October 2005 14:40 Go to previous message
Robert Moss is currently offline  Robert Moss
Messages: 74
Registered: February 1996
Member
psbeps@hotmail.com wrote:
> I am trying to round to the nearest tenth, and it works most of the
> time. It doesn't work if the value is 5.05 or 5.55, which get rounded
> to 5.0 and 5.5, respectively, instead of 5.1 and 5.6. When I type it
> into the command line, it works as expected, but not when I run the
> entire program.
>
> Here is the code (which I have divided into steps to see where it's
> going wrong--it still doesn't work if I do the same thing in one line
> of code):
>
> ;** Round off the value.
> help, value
> print, value
> temp = value * 10.0
> help, temp
> print, temp
> rounded_value = ROUND(temp)
> help, rounded_value
> print, rounded_value
> value = rounded_value/10.0
> help, value
> print, value
>
> Here is the output:
> VALUE FLOAT = 5.05000
> 5.05000
> TEMP FLOAT = 50.5000
> 50.5000
> ROUNDED_VALUE LONG = 50
> 50
> VALUE FLOAT = 5.00000
> 5.00000
>
> Why does it not round properly?
>
> Jill
>

If it works at the command line (which this code does), but it does not
work in a program, you are probably looking in the wrong place for the
error. In other words, the error is not in the lines above, but probably
somewhere after that (assuming that the lines above tell the whole
story). Post the actual problem code and we can probably help you.

--
Robert Moss, PhD
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Lost iTool macros in move from 6.1 to 6.2
Next Topic: default plot window size in IDL 6.2

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

Current Time: Wed Oct 08 15:53:18 PDT 2025

Total time taken to generate the page: 0.00439 seconds