How to round a number?
The example below show you some methods of the
Math class that can be use to round the value of a number. These methods are
Here are the result of the program:
Result of rounding up of 1.5 = 2.0
Result of rounding down of 1.5 = 1.0
Rounding result of 1.5 (in long) = 2
Rounding result of 1.5 (in int) = 2