1. Math.Round
Returns a close integer value, which is actually what we call rounding a decimal.
/** * Returns the nearest parameter of long */staticlong round (double a)/** */static int round (float a)
Examples are as follows:
- Math.Round (8.1): 8
- Math.Round (8.4): 8
- Math.Round (8.5): 9
- Math.Round (8.9): 9
- Math.Round (-8.1): 8
- Math.Round (-8.4): 8
- Math.Round ( -8.5):-8// negative numbers are different from integers. When the first decimal point is less than or equal to 5, carry is carried , so get-8
- Math.Round (-8.9):-9//when the first decimal place is greater than 5 o'clock, the loft is carried out. 9 is the next integer less than-8, so get-9
2. Math.floor
is actually the double type that returns the maximum integer value that is not greater than the parameter.
/***/staticdouble floor (double a )
Examples are as follows:
Math.floor (8.9): 8.0
Math.floor (8.1): 8.0
Math.floor (-8.1): 9.0
Math.floor (-8.9): 9.0
3. Math.ceil
In contrast to Math.floor, the double type that returns the smallest integer value that is not less than the parameter.
/***/staticdouble ceil (double a)
Examples are as follows:
Math.ceil (8.9): 9.0
Math.ceil (8.1): 9.0
Math.ceil (-8.1): 8.0
Math.ceil (-8.9): 8.0
Easy to confuse some of the math method descriptions