Math.ceil() Method - Math Functions

Math.Ceil() method of Math Functions in Javascript.
How to round off to greater value of a number in javascript?

Explanation

Object: Math
Method: Math.ceil()
Description: To get the number rounded to the next greater value of a number. The below example will round off to greater value of a number using math functions.

Example:


<html>
<input type=button onclick="ceil()" name="button" value="ceil a number">
<script type="text/javascript">
function ceil(){
ceilval = prompt("Enter a number:", " ");
alert('Round off value of the number is::'+Math.ceil(ceilval));
}
</script>
</html>

Result:




In the above example,
  • User is prompted to enter a number.
  • Math.ceil() function is used to return the ceiled result as an alert.


Ask Questions

Ask Question