rounding up negative floating literal java

Why does -0.5 when being passed on the Math.round results to 0? and 0.5 when being passed also results to 1? shouldn't it be that when you pass -0.5 to Math.round() should also produce -1 as result? I obtained the -1 result when the number was -0.6.

Jon Skeet
people
quotationmark

Math.round(double) is documented as:

Returns the closest long to the argument, with ties rounding to positive infinity.

So -0.5 is rounding up (towards positive infinite) instead of down towards negative infinity. It's behaving exactly as documented.

people

See more on this question at Stackoverflow