AD · 728×90
Google AdSense / Яндекс.Директ
Google AdSense / Яндекс.Директ
Math
Math.floor()
Returns the largest integer less than or equal to a given number (rounds down)
Number to round down
Math.floor(x)
RESULT
— click Run or press Ctrl+Enter —
Parameter Reference
| Parameter | Type | Status | Description |
|---|---|---|---|
| x | number | required | Number to round down |
About
Math.floor() always rounds toward negative infinity — the largest integer <= input. Widely used for generating random integers, computing page numbers, and working with pixel coordinates. Math.floor(-4.1) = -5, not -4.
Browser Support
Available since ES1 (1997). Behavior is fully standardized and identical across all browsers and Node.js.
Tips & Gotchas
- Math.floor(-4.1) === -5, not -4 — rounds toward -∞
- random int from 0 to N-1: Math.floor(Math.random() * N)
- bitwise OR (x | 0) is faster but only works within 32-bit int range.