Round a float up to the next integer with Math.ceil - Javascript Math

Javascript examples for Math:ceil

Description

Round a float up to the next integer with Math.ceil

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
var n = 35.85001;//from  w  w  w  . ja va  2 s.  co  m
console.log(Math.ceil(n * 100) / 100);  // 35.86
var n = 35.800001;
console.log(Math.ceil(n * 10) / 10);    // 35.9
var n = 35.00001;
console.log(Math.ceil(n));              // 36

      </script>  
   </body>
</html>

Related Tutorials