the round is rounded ... Ceiling is rounding up. Float is rounded down
Here are a few ways to round decimal values to integers: Math.ceil (), Math.floor (), and Math.Round (). These three methods follow the following rounding rules, respectively:
Math.ceil () performs an upward rounding, that is, it always rounds the value up to the nearest integer;
Math.floor () Performs a downward rounding, that is, it always rounds the value down to the nearest integer;
Math.Round () performs a standard rounding, that is, it always rounds a number to the nearest integer (which is also the rounding rule we learned in math Class).
The following are examples of using these methods:
For all values between 25 and 26 (not including 26), Math.ceil () always returns 26 because it performs rounding up. The Math.Round () method returns 26 only if the value is greater than or equal to 25.5, or 25. Finally, Math.floor () returns 25 for all values between 25 and 26 (not including 26).
Here are some additions:
Ceil (): The fractional part is rounded to the integer part.
Such as:
$ (this). Animate ({left: "+=500px", Height: "300px", Opacity: "0.5"},3000)
Math.ceil (12.2)//return 13
Math.ceil (12.7)//return 13
Math.ceil (12.0)//return 12
Floor (): All are left, only integers are reserved.
Such as:
Math.floor (12.2)//return 12
Math.floor (12.7)//return 12
Math.floor (12.0)//return 12
Round (): Rounding
Such as:
Math.Round (12.2)//return 12
Math.Round (12.7)//return 13
Math.Round (12.0)//return 12
$ (this). Animate ({left: "+=500px", Height: "300px", Opacity: "0.5"},3000)
The difference between Javascript Math ceil (), floor (), round () three functions