One source of confusion is the thought of "truncating" the digits that are to the right of the decimal point. Don't think of it that way because that is not what's happening. Just remember, as the other people posting here have pointed out, that the algorithm for Math.round() is to add 0.5 and then perform a Math.floor(), which returns the nearest integer less than or equals to the value passed.
-2.9 + .5 = -2.4 Math.floor(-2.4) lowers the result to -3.0 Since Math.round(double) returns a long, the final result returned is equivalent to -3L
SCJA 1.0 (98%), SCJP 1.4 (98%)
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, that will fit in a stocking