freeCodeCamp/guide/english/javascript/standard-objects/math/math-ceil/index.md

20 lines
687 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Math Ceil
---
## Math Ceil
The `Math.ceil()` is a method of the Math standard object that rounds a given number upwards to the next integer. Take note that for negative numbers this means that the number will get rounded "towards 0" instead of the number of greater absolute value (see examples).
### Examples
```javascript
Math.ceil(0.1) // 1
Math.ceil(1.3) // 2
Math.ceil(-0.9) // -0
Math.ceil(-1.5) // -1
```
### More Information:
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil)
* [w3schools](https://www.w3schools.com/jsref/jsref_ceil.asp)
* [Wikipedia](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions)