+ 1
Math.rint
Can anybody explain why Math.rint(11.5) vs Math.rint(12.5) have the same result?
3 Answers
+ 4
When 2 numbers are of equal distance (x.5) the result will be the even number.
So 11.5 rounds to 12. Since 12 is even, 11 is not.
12.5 rounds to 12, Since 12 is even, 13 is not.
+ 2
Just when it comes to the .5,
round() will round up in this case.
+ 1
thanks, I thought Math.rint is pretty much the same thing as Math.round.