A brief discussion on the differences of three kinds of integral functions in java class math

  • 2020-05-16 06:55:13
  • OfStack

3 big integer functions in class math

1.ceil

2.floor

3.round

In fact, it is quite easy to take the whole of the three functions. As long as you remember the names of the three functions translated into Chinese, you can understand the three functions easily

1.ceil, which means ceiling, which is called rounding up, is greater than or equal to the nearest integer of the number

Ex. :
math.ceil(13.2)=14

math.ceil(-13.2)=-13

2.floor, which means floor, and java, which is called rounding down, is less than or equal to the nearest integer to the number

Ex. :
math.floor(13.2)=13

math.floor(-13.2)=-14

3.round, the most special, is actually 4 rounds 5 in

Ex. :
math.round(13.2)=13;math.round(13.5)=14

math.round(-13.2)=-13,math.round(-13.5)=-13


Related articles: