Transfer: https://www.cnblogs.com/langtianya/p/6321911.html
ParseInt (5/2) parseInt(5/2)
2. Round up. If there is a decimal, add 1 to the whole number
Math.ceil(5/2)
3. Round.
Math.round(5/2)
4. Round down
Math.floor(5/2)
Method of the Math object
methods | describe |
---|---|
abs(x) | Returns the absolute value of a number |
acos(x) | Returns the arccosine of a number |
asin(x) | Returns the arcsine of a number |
atan(x) | Returns the arctangent of x 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) | Round up a number. |
cos(x) | Returns the cosine of the number |
exp(x) | Returns the exponent of e. |
floor(x) | Round down a number. |
log(x) | The natural logarithm of the number returned (base 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) | Return x to the y power |
random() | Returns a random number between 0 and 1 |
round(x) | Round a number to the nearest whole number |
sin(x) | Return the sine of a number |
sqrt(x) | Returns the square root of the number |
tan(x) | Returns the tangent of an Angle |
toSource() | Represents the source code of the object |
valueOf() | Returns the original value of a Math object |
ToFixed (); toFixed(); toFixed();