Javascript Math Ceil Function

by top54u.com 21 Jul, 2008

Math Ceil function of Javascript returns the nearest greater value to the specified number. Math Ceil Function means the ceiling value i.e. upper value for the specified value. Math.ceil(x) function returns the upper nearest value for the specified number. Math.ceil function rounds off the specified number similar to the Math.round function as we discussed in the previous tutorial about Javascript Math Round Function. If round off process of Math.ceil function gets the precision point value greater than 0 then Math.ceil function return the number 1 greater than the number passed to it. Javascript Math Ceil function also returns the integer value by rounding of the precision point values resulting to its significant integer value.

 

Syntax for Javascript Math Ceil Function

 

Math.ceil(x);

Math.ceil function accepts value as number and returns the upper nearest integer value for it.

 

 

Examples of Javascript Math Ceil Function

 

<script language="javascript" type="text/javascript">

document.write(Math.ceil(0.51) + "<br />");

document.write(Math.ceil(2) + "<br />");

document.write(Math.ceil(2.1) + "<br />");

document.write(Math.ceil(2.84) + "<br />");

document.write(Math.ceil(-2.44) + "<br />");

document.write(Math.ceil(-6.44) + "<br />");

document.write(Math.ceil(-6.94) + "<br />");

</script>

 

Output

1
2
3
3
-2
-6
-6

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:37:45 AM




related videos.....
recent posts.....
top54u ezines.....