On the differences of three rounding functions in math class in Java
Three rounding functions in math class
1.ceil
2.floor
3.round
In fact, the three rounding functions are quite simple As long as you remember the three function names, the translated Chinese can easily understand the three functions, which are introduced one by one below
1. Ceil, which means ceiling, is called rounding up in Java, and is the nearest integer greater than or equal to the number
Example: math ceil(13.2)=14
math. ceil(-13.2)=-13
2. Floor, which means floor, is called rounding down in Java. It is the nearest integer less than or equal to this number
Example: math floor(13.2)=13
math. floor(-13.2)=-14
3. Round, the most special, is actually rounding
Example: math round(13.2)=13; math. round(13.5)=14
math. round(-13.2)=-13,math. round(-13.5)=-13
The difference between the three rounding functions in the math class in Java is all the content shared by Xiaobian. I hope I can give you a reference and support more programming tips.