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)
Math Object Properties
| Properties |
Description |
| E |
Returns the arithmetic constant E, which is the base of the natural logarithm (approximately equal to 2.718). |
| LN2 |
Returns the natural logarithm of 2 (approximately equal to 0.693). |
| LN10 |
Returns the natural logarithm of 10 (approximately equal to 2.302). |
| Log2e |
Returns the logarithm of E with a base of 2 (approximately equal to 1.414). |
| log10e |
Returns the logarithm of E with a base of 10 (approximately equal to 0.434). |
| Pi |
Returns the Pi (approximately equal to 3.14159). |
| Sqrt1_2 |
Returns the reciprocal of the square root that returns 2 (approximately equals 0.707). |
| SQRT2 |
Returns the square root of 2 (approximately equal to 1.414). |
Math Object method
| Method |
Description |
| ABS (x) |
The absolute value of the return number. |
| ACOs (x) |
The inverse cosine value of the returned number. |
| ASIN (x) |
Returns the inverse chord value of the number. |
| Atan (x) |
Returns the inverse tangent of x with a value between-PI/2 and PI/2 radians. |
| ATAN2 (y,x) |
Returns the angle from the x-axis to the point (X, y) (between-PI/2 and PI/2 radians). |
| Ceil (x) |
The logarithm is rounded up. |
| COS (x) |
The cosine of the returned number. |
| EXP (x) |
Returns the exponent of E. |
| Floor (x) |
The logarithm is rounded down. |
| Log (x) |
Returns the natural logarithm of the number (bottom is e). |
| Max (x, y) |
Returns the highest value in X and Y. |
| Min (x, y) |
Returns the lowest value in X and Y. |
| Pow (x, y) |
Returns the Y power of X. |
| Random () |
Returns a random number between 0 and 1. |
| Round (x) |
Rounds the number to the nearest integer. |
| Sin (x) |
Returns the sine of a number. |
| sqrt (x) |
Returns the square root of the number. |
| Tan (x) |
Returns the tangent of a corner. |
| Tosource () |
Returns the source code for the object. |
| ValueOf () |
Returns the original value of the Math object. |
JS Math function