javascript ceil() method


  Translation results:

UK[si:l] US[si:l]

vt. Install the ceiling, install the grid board in the ship

Third person singular: ceils Present participle: ceiling Past tense: ceiled Past Participle: ceiling

javascript ceil() methodsyntax

Function: Round up a number.

Syntax: Math.ceil(x)

Parameters: x Required. Must be a numeric value.

Returns: is greater than or equal to x and is the closest integer to it.

Description: The ceil() method performs rounding up calculation, and it returns the integer that is greater than or equal to the function parameter and is the closest to it.

javascript ceil() methodexample

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">
//把 ceil() 方法运用到不同的数字上
    document.write(Math.ceil(0.60) + "<br />")
    document.write(Math.ceil(0.40) + "<br />")
    document.write(Math.ceil(5) + "<br />")
    document.write(Math.ceil(5.1) + "<br />")
    document.write(Math.ceil(-5.1) + "<br />")
    document.write(Math.ceil(-5.9))

</script>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A