This week's book giveaway is in the Jobs Discussion forum. We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line! See this thread for details.

Keep in mind that .5 rounds up to the next highest inter. For example, 1.5 will round up to 2. So, what will -1.5 round up to? -1 and not -2 because you are rounding the number to the next highest integer--which is -1 and not -2. oops...Cindy beat me by 2 minutes. What she said is correct. [This message has been edited by js yang (edited June 10, 2001).]

payal bansal
Greenhorn

Joined: May 01, 2001
Posts: 23

posted

0

Thanks for replying. But do tell me onething------ when float f4 = -5.6f; Math.round(f4)-------->-6 Why??? Why don't it roundsup to -5?

payal bansal
Greenhorn

Joined: May 01, 2001
Posts: 23

posted

0

Thanks for replying. But do tell me onething------ when float f4 = -5.6f; Math.round(f4)-------->-6 Why??? Why don't it roundsup to -5?

Payal, The round method will round to the nearest integer, which in the case of -5.6 would be -6. The rounding to -5 would apply for values of -5.5 to -5.0. On a number line: <pre> neg <--|--.--.--.--.--|--|--.--.--.--|----> pos -6 -5.6 -5.5 -5.0 </pre>

Originally posted by payal bansal: Thanks for replying. But do tell me onething------ when float f4 = -5.6f; Math.round(f4)-------->-6 Why??? Why don't it roundsup to -5?