JavaScript Math.floor()
Beispiel
let x = Math.floor(1.6);
Definition und Verwendung
Die Methode Math.floor() rundet eine Zahl ABWÄRTS auf die nächste Ganzzahl und gibt das Ergebnis zurück.
Mehr Beispiele
let a = Math.floor(0.60);
let b = Math.floor(0.40);
let c = Math.floor(5);
let d = Math.floor(5.1);
let e = Math.floor(-5.1);
let f = Math.floor(-5.9);
Browser-Unterstützung
Math.floor()
ist eine ECMAScript1 (ES1)-Funktion.
ES1 (JavaScript 1997) wird in allen Browsern vollständig unterstützt:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.floor(x)
Parameter
Parameter | Description |
---|---|
x | Required. The number to round. |
Rückgabewert
Eine Zahl, die beim Abrunden die nächste Ganzzahl darstellt. |