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.
Die statische Methode Math.ceil()
rundet immer auf und gibt die kleinste ganze Zahl zurück, die größer oder gleich einer gegebenen Zahl ist.
Probieren Sie es aus
console.log(Math.ceil(0.95));
// Expected output: 1
console.log(Math.ceil(4));
// Expected output: 4
console.log(Math.ceil(7.004));
// Expected output: 8
console.log(Math.ceil(-7.004));
// Expected output: -7
Syntax
Math.ceil(x)
Parameter
x
-
Eine Zahl.
Rückgabewert
Die kleinste ganze Zahl, die größer oder gleich x
ist. Dies entspricht dem Wert von -Math.floor(-x)
.
Beschreibung
Da ceil()
eine statische Methode von Math
ist, wird sie immer als Math.ceil()
verwendet und nicht als Methode eines selbst erstellten Math
-Objekts (Math
ist kein Konstruktor).
Beispiele
Verwendung von Math.ceil()
Math.ceil(-Infinity); // -Infinity
Math.ceil(-7.004); // -7
Math.ceil(-4); // -4
Math.ceil(-0.95); // -0
Math.ceil(-0); // -0
Math.ceil(0); // 0
Math.ceil(0.95); // 1
Math.ceil(4); // 4
Math.ceil(7.004); // 8
Math.ceil(Infinity); // Infinity
Spezifikationen
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.ceil |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ceil |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support