+ 1

Explain this code?

Double r = Math.rint(9.5) + Math.rint(11.5); System.out.println(r); Why the Output is 22.0.

21st Jan 2019, 11:45 AM
Nitin Gutte
Nitin Gutte - avatar
1 Answer
+ 6
Just by looking at it, it is rounding the numbers: 9.5 -> 10, 11.5 -> 12 10 + 12 = 22.
21st Jan 2019, 12:21 PM
Dread
Dread - avatar