JS Take integer rounding
1. Discard the fractional part, preserving the whole number of parts
parseint (5/2)
2. Rounding up, with decimals on the integer part plus 1
Math.ceil (5/2)
3, rounded.
Math.Round (5/2)
4, rounding down
Math.floor (5/2)
Methods of the Math object
Ff:firefox, N:netscape, Ie:internet Explorer
| Method |
Description |
FF |
N |
IE |
| ABS (x) |
The absolute value of the return number |
1 |
2 |
3 |
| ACOs (x) |
Inverse cosine value of the return number |
1 |
2 |
3 |
| ASIN (x) |
The inverse chord value of the returned number |
1 |
2 |
3 |
| Atan (x) |
Returns the inverse tangent of x with a value between-PI/2 and PI/2 radians |
1 |
2 |
3 |
| ATAN2 (y,x) |
Returns the angle from x-axis to point (x, y) (between-PI/2 and PI/2 radians) |
1 |
2 |
3 |
| Ceil (x) |
Rounds a number. |
1 |
2 |
3 |
| COS (x) |
Cosine of the returned number |
1 |
2 |
3 |
| EXP (x) |
Returns the exponent of E. |
1 |
2 |
3 |
| Floor (x) |
Rounds down a number. |
1 |
2 |
3 |
| Log (x) |
Natural logarithm of the number of returns (Bottom is E) |
1 |
2 |
3 |
| Max (x, y) |
Returns the highest value in X and Y |
1 |
2 |
3 |
| Min (x, y) |
Returns the lowest value in X and Y |
1 |
2 |
3 |
| Pow (x, y) |
Returns the Y power of X |
1 |
2 |
3 |
| Random () |
Returns a random number between 0 ~ 1 |
1 |
2 |
3 |
| Round (x) |
Rounding a number to the nearest integer |
1 |
2 |
3 |
| Sin (x) |
The sine of the returned number |
1 |
2 |
3 |
| sqrt (x) |
The square root of the returned number |
1 |
2 |
3 |
| Tan (x) |
Returns the tangent of a corner |
1 |
2 |
3 |
| Tosource () |
The source code that represents the object |
1 |
4 |
- |
| ValueOf () |
Returns the original value of a Math object |
|
|
|
JS Take integer rounding