ceil()  Math  class methodS2C Home  « Globals « Math « ceil()

Description

Returns the smallest integer greater than or equal to a number.

  • Like all class methods ceil() should be used on the class rather than an instance of the class.

Syntax

Signature Description
Math.ceil(value)Returns the smallest integer greater than or equal to a number.

Parameters

Parameter Description
valueThe value you wish to find the ceiling value for:
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.

Examples

The code below displays ceil() usage.


/*
 * Store results in an array.
 */ 
var ceilValues = new Array(6);
ceilValues[0] = Math.ceil(1.9);
ceilValues[1] = Math.ceil(-10.8);
ceilValues[2] = Math.ceil('100.1');
ceilValues[3] = Math.ceil('five');
ceilValues[4] = Math.ceil();
ceilValues[5] = Math.ceil(null);
alert(ceilValues);  

Press the button below to action the above code:


Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math

go to home page Homepage go to top of page Top