JS Built-ins
← Math87 / 215
Mathceilbeginner

Math.ceil(-4.1) Equals -4

πŸ“– Usage Example
// Round up to the nearest integer
Math.ceil(4.2)   // β†’ 5
Math.ceil(-4.2)  // β†’ -4

Use Math.ceil() when you need to round a number up to the next whole integer.

Math.ceil(x)

For negative numbers, Math.ceil() rounds toward zero. Math.ceil(-4.1) returns -4.

Challenge: Use Math.ceil() on a negative number.

πŸ’‘ Hints (2)
  • β€’ ceil always rounds toward +∞, which for negatives means toward zero
  • β€’ Compare with Math.floor(-4.1) = -5