Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. Math
  6. ceil()

Math.ceil()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheMath.ceil() static method always rounds up and returns the smallest integer greater than or equal to a given number.

Try it

console.log(Math.ceil(0.95));// Expected output: 1console.log(Math.ceil(4));// Expected output: 4console.log(Math.ceil(7.004));// Expected output: 8console.log(Math.ceil(-7.004));// Expected output: -7

Syntax

js
Math.ceil(x)

Parameters

x

A number.

Return value

The smallest integer greater than or equal tox. It's the same value as-Math.floor(-x).

Description

Becauseceil() is a static method ofMath, you always use it asMath.ceil(), rather than as a method of aMath object you created (Math is not a constructor).

Examples

Using Math.ceil()

js
Math.ceil(-Infinity); // -InfinityMath.ceil(-7.004); // -7Math.ceil(-4); // -4Math.ceil(-0.95); // -0Math.ceil(-0); // -0Math.ceil(0); // 0Math.ceil(0.95); // 1Math.ceil(4); // 4Math.ceil(7.004); // 8Math.ceil(Infinity); // Infinity

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-math.ceil

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp