Math.ceil( ) In JavaScript

The Math.ceilfunction in JavaScript is used to return the smallest integer greater than or equal to a given number.
Ceil() is always used as Math.ceil() since it is a static method of Math.

Syntax:

Math.ceil(value)

Parameters Used:
Value :It is the value which is to be tested for Math.ceil.



Return Value:
The Math.ceil() function returns the smallest integer greater than or equal to the given number.

Examples:

Input : Math.ceil(.89)
Output : 1
     
Input :  Math.ceil(-89.02)
Output : -89

Input : Math.ceil(0)
Output : 0

  1. When a number less than zero is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
             document.write("Output : " + Math.ceil(.89));                   
          </script>

    chevron_right

    
    

    Output:

    Output : 1
  2. When a negative number is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
             document.write("Output : " + Math.ceil(-89.02));                   
          </script>

    chevron_right

    
    

    Output:

    Output : -89
  3. When zero is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
             document.write("Output : " + Math.ceil(0));                   
          </script>

    chevron_right

    
    

    Output:

    Output : 0


  4. My Personal Notes arrow_drop_up

    I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




    Article Tags :

    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.