Rounding off Decimal rounding: Math.floor (2) =2
Rounding off Decimal rounding: Math.floor (2.1) =2
Rounding off Decimal rounding: Math.floor (-2.1) =-3
Rounding off Decimal rounding: Math.floor (-2.5) =-3
Rounding off Decimal rounding: Math.floor (2.9) =2
Rounding off Decimal rounding: Math.floor (-2.9) =-3
Summary: Math.floor (x) = largest integer less than x
Rounding off Decimals: Math.ceil (2) =2
Rounding off Decimals: Math.ceil (2.1) =3
Rounding off Decimals: Math.ceil (2.5) =3
Rounding off Decimals: Math.ceil (-2.5) =-2
Rounding off Decimals: Math.ceil (2.9) =3
Rounding off Decimals: Math.ceil (-2.9) =-2
Summary: Math.ceil (x) = smallest integer not less than X
Rounded rounding: Math.Round (3.1) 3
Rounded rounding: Math.Round (3.5) 4
Rounded rounding: Math.Round (-3.1)-3
Rounded rounding: Math.Round (-3.5)-3
Summary: Math.Round (x) = Math.floor (x+0.5) (rounding in mathematical sense)
Rounded rounding: Math.rint (2) =2
Rounded rounding: Math.rint (2.1) =2
Rounded rounding: math.rint (-2.5) =-2
Rounded rounding: math.rint (2.5) =2
Rounded rounding: Math.rint (2.9) =3
Rounded rounding: Math.rint (-2.9) =-3
Rounded rounding: Math.rint (-2.49) =-2
Rounded rounding: Math.rint (-2.51) =-3
Special case: Math.rint ()
1. If the parameter itself is an integer, it returns itself.
2. If it is not a number or infinity or plus or minus 0, the result is itself
Summary: Floor is rounded down, ceil upward, round and rint rounded, rounded with absolute values, and then added with symbols, when encountered. 5. Take even that.
This article is from the "Foreverhela" blog, make sure to keep this source http://feven1994.blog.51cto.com/10602437/1683460
Summing up the method of math rounding