How to use ceil in JavaScript

In this article, I will explain use of ceil() method in JavaScript.
  • 1999

JavaScript ceil() Method

  • ceil() method of math object is used to get rounds a number UPWARDS to the nearest integer.

  • ceil() method returns the smallest integer greater than or equal to a number.

  • In ceil() method, if the argument value is an integer, the value will not be rounded.



  • x is a Required number, you want to round


In the following example show to ceil() method returns smallest integer of numbers.



<title>JavaScript Math ceil() Method</title>



<h3 style="color:Blue">JavaScript ceil() Method Example</h3>

<script type="text/javascript">

    var a = Math.ceil(65.90);

    document.write("First Value of ceil : " + a);

    var b = Math.ceil(25.95);

    document.write("<br />Second Value of ceil : " + b);

    var c = Math.ceil(-65.90);

    document.write("<br />Third Value of ceil: " + c);

    var d = Math.ceil(-25.95);

    document.write("<br />Fourth Value of ceil: " + d);





ceil method.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.