Math.ceil()

JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE3+, Opera3+ Syntax

							math.ceil(num)
						

Description

The ceil() method of the Math object is used to calculate the smallest integer that is greater than or equal to the number passed in as a parameter. This is similar to getting the ceiling of a number.

Example

Listing 6.156 shows how the ceil() method is used to get the largest integer for the number input by the user.

Listing 6.156 Example of the ceil() Method
 <html> <body> <title>Example of the ceil() method</title> <script language="JavaScript"> <!–– Hide // function calculates the ceiling integer. // takes input and passes it to the ceil method. function doMath(){ var inputNum=document.form1.input.value; var result ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.