1. Discard the decimal part and keep the integer part
parseInt(5/2)
2. Round upwards, add 1 to the integer part if there is a decimal.
(5/2)
3. Round.
(5/2)
4. Round downward
(5/2)
Methods of Math object
FF: Firefox, N: Netscape, IE: Internet Explorer
Method Description FF N IE
abs(x) Returns the absolute value of the number 1 2 3
acos(x) Returns the inverse cosine value of the number 1 2 3
asin(x) Returns the inverse sine value of the number 1 2 3
atan(x) returns the arctangent value of x as a value between -PI/2 and PI/2 radians 1 2 3
atan2(y,x) Returns the angle from the x axis to the point (x,y) (between -PI/2 and PI/2 radians) 1 2 3
ceil(x) Round up a number. 1 2 3
cos(x) returns the cosine of the number 1 2 3
exp(x) returns the exponent of e. 1 2 3
floor(x) Round down a number. 1 2 3
log(x) Returns the natural logarithm of the number (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 of 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 and 1 1 2 3
round(x) rounds a number to the closest integer 1 2 3
sin(x) returns the sine of the number 1 2 3
sqrt(x) returns the square root of the number 1 2 3
tan(x) returns the tangent of an angle 1 2 3
toSource() represents the source code of the object 1 4 -
valueOf() Returns the original value of a Math object