+ 7
What is the difference between Math.rint() method and Math.round() method ?
Math.round(2.5)=3.0 but Math.rint(2.5)=2.0
2 Answers
+ 1
java.lang.Math.rint(double a)Â returns the double value that is closest in value to the argument and is equal to a mathematical integer. If two double values that are mathematical integers are equally close, the result is the integer value that is even.
Math.round will round up 1/2 regardless of the number, rint will only round up odd 'halves'