Hi Siva,
Originally posted by Sivalingam Sivasuthan:
-5.0 <=f <= -5.5 then Math.round(f)==-5.0
-5.5 < f < -6.0 then Math.round(f)==-6.0
There is
not such number 'f' that,
-5.0 <=f <= -5.5 or -5.5 < f < -6.0,
since -5.0 is greater than -5.5 and -5.5 is greater than -6.0.
The correct way to find a rounded value is to find the floor value of given number plus 0.5.
So, floor(-5.5 + 0.5) = floor(-5.0) = -5.0
floor(-5.49 + 0.5) = floor(-4.99) = -5.0
NB: floor value of a number is defined as 'the highest integer value that is less than or equals to the given number.
... -7.0, -6.0, -5.0 are less than or equals to -4.99 or -5.00, but -5.0 is the highest.
Arul.
[This message has been edited by Bala Arul (edited February 16, 2001).]