Share the next JS to take integers, take the remainder of the method.
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) absolute value of the return number 1 2 3
ACOs (x) inverse cosine of the return number 1 2 3
ASIN (x) inverse sine of the number of returns 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 the x-axis to the point (X, y) (between-PI/2 and PI/2 radians) 1 2 3
Ceil (x) rounds a number. 1 2 3
COS (x) The cosine of the return 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) The natural logarithm of the number of returns (base 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
The POW (x, y) returns the y power of x 1 2 3
Random () returns 0 to 1 of the stochastic number 1 2 3
Round (x) rounding a number to the nearest integer 1 2 3
Sin (x) returns the sine of the number 1 2 3
sqrt (x) The square root of the number of returns 1 2 3
Tan (x) returns the tangent of a corner 1 2 3
Tosource () represents the source code of the object 1 4-
ValueOf () returns the original value of a Math object
Example:
<script type= "Text/javascript" >//take the wholefunctionGetResult (num) {returnparseint (num);}//rounding to n bits behind NumfunctionGetResult (num,n) {returnMath.Round (Num*math.pow (10,n))/math.pow (10,n);} www.jbxue.com//Intercept n BitsfunctionGetResult (num,n) {returnNum.tostring (). Replace (NewRegExp ("^ (\\-?\\d*\\.? \\d{0, "+n+"}) (\\d*) $ ")," $ ") +0;}</script>
Other:
var mlength =var////var// if(mlast>0) {$ (". Mood_content"). Height ((mfirst+1) *20);}