This week's book giveaway is in the OCAJP 8 forum.We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!See this thread for details.
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!

# Clarify... Math Functions....

Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
How does the Math.round() function work for negative numbers... Explain with examples...

\$Hi/\bEr
Pinkal Patel
Ranch Hand

Joined: Jun 16, 2006
Posts: 57
Math.round()
Will work same as abs number ...

Only diffrance is
Upto .5 it will tack lower range
and than onverds it will tack upper limit

Pinkal Patel<br />SCJP 1.5<br />Preparing for SCWCD
Shiaber Shaam
Ranch Hand

Joined: Jun 16, 2006
Posts: 252
Give example....
Pramila Chinguru
Ranch Hand

Joined: May 05, 2006
Posts: 54
Math.round is calculated as below
1. add 0.5 to the number
2. then,take the floor of it.

Eg 1: 2.4

1. 2.9
2. Floor(2.9) = 2 (not 2.0, since round returns either long or int).

Eg 2: -2.4

1. -1.9
2. floor(-1.9) = -2

point of note: floor of negative number is equivalent to ciel of its positive number.
krish bajaj
Ranch Hand

Joined: Jun 19, 2006
Posts: 31
hello there

yes shaiber pramila is exactly write

I agree. Here's the link: http://aspose.com/file-tools

subject: Clarify... Math Functions....