Http: // 221.199.150.103/JSJ/html/page/book/JS/j_math_ceil.htm
Math Ceil ()
,
Floor ()
,
Round ()
Method
Math. Ceil () |
Function:The number is rounded up.Syntax:Math. Ceil (X)Parameters:
Return Value:Returns an integer that is greater than or equal to X and closest to the nearest value.Note:If X is a positive number, the decimal number is "in". If X is a negative number, the decimal number is "out ". Example: <SCRIPT type = "text/JavaScript"> Document. write (math. ceil (1.2) + "," + math. ceil (1.8) + "," + math. ceil (-1.2) + "," + math. ceil (-1.8 )); </SCRIPT> the output result is: Document. write (math. ceil (1.2) + "," + math. ceil (1.8) + "," + math. ceil (-1.2) + "," + math. ceil (-1.8 )); 2, 2,-1,-1 |
Math. Floor () |
Function:Perform a rounded down operation on a number.Syntax:Math. Floor (X)Parameters:
Return Value:Returns an integer that is less than or equal to X and closest to X.Note:If X is a positive number, the decimal number is "included". If X is a negative number, the decimal number is "in ". Example: <SCRIPT type = "text/JavaScript"> Document. write (math. floor (1.2) + "," + math. floor (1.8) + "," + math. floor (-1.2) + "," + math. floor (-1.8 )); </SCRIPT> the output result is: Document. write (math. floor (1.2) + "," + math. floor (1.8) + "," + math. floor (-1.2) + "," + math. floor (-1.8 )); 1, 1,-2,-2 |
Math. Round () |
Function:Rounding.Syntax:Math. Round (X)Parameters:
Return Value:The nearest integer to X. Example: <SCRIPT type = "text/JavaScript"> Document. write (math. round (1.2) + "," + math. round (1.8) + "," + math. round (-1.2) + "," + math. round (-1.8 )); </SCRIPT> the output result is: Document. write (math. round (1.2) + "," + math. round (1.8) + "," + math. round (-1.2) + "," + math. round (-1.8 )); 1, 2,-1,-2 |