Re: fix(4.70*100) is... 469 [message #53563 is a reply to message #53562] |
Thu, 19 April 2007 01:13   |
Paolo Grigis
Messages: 171 Registered: December 2003
|
Senior Member |
|
|
b_efremova@yahoo.com wrote:
> Hi Guys,
> There's something I can not explain to myself, so maybe someone can
> enlighten me?
> print,fix(4.70*100)
> 469
> and also:
> print,string(4.70*100,format='(i3)')
> 469
>
>
> While, everything else that came into my head to try was OK like:
> print,fix(5.70*100)
> 570
> print,fix(3.70*100)
> 370
> print,fix(4.60*100)
> 460
> print,string(4.60*100,format='(i3)')
> 460
> ...
> etc..
>
> Thanks in advance!
> Cheers.
> Boryana
>
Personally, I think "fix" should be used with some care,
because the documentation is a bit vague on how the
conversion to integer type is done, and the result does
depend on the input type. For numerical values, I think
that usage of "round", "ceil" or "floor" is safer (but be
aware that they produce long integers if the input
is large enough, but this is mostly what you want anyway).
Ciao,
Paolo
|
|
|