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.
Math.ceil(x);
Math.ceil function accepts value as number and returns the upper nearest integer value for it.
<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
Be the first to rate this post
Tags: javascript, javascript math.ceil, javascript math functions, javascript math object, javascript math properties, javascript math.abs, javascript math ceil function, javascript math.floor, javascript math.pow, javascript math.log, javascript math round function, javascript math.sqrt, javascript math.random
10/11/2008 3:37:45 AM