0x01
In the Java Math class there are three methods for floating-point numbers to take integers, namely ceil (rounding up) floor (rounded down) roundthree methods
0x02 ceil upward rounding, after rounding is always larger than the original number.
System. out. println (Math.ceil (2.34)); System. out. println (Math.ceil (-2.34));
3.0
-2.0
0x03 floor is rounded down and is always smaller than the original number.
System. out. println (Math.floor (2.34)); System. out. println (Math.floor (-2.34)); 2.0-3.0
0x04 Round rounding, the most complex is the round, the algorithm is Math.floor (x+0.5), that is, the original data plus 0.5 in the downward rounding
System.out.println (Math.Round (2.34)); System.out.println (Math.Round (2.65)); System.out.println (Math.Round (-2.5)); System.out.println (Math.Round (-2.49));
2
3
-2
-2
Java three rounding methods for the math class