Number.toInt
toInt() -> number
Description
Convert number to an integer, by dropping all digits after the decimal point.
$num = 123.456 $num.toInt() //= 123 $num = -5.67 $num.toInt() //= -5
Comparison of Rounding Methods
| Method | Description | Example |
|---|---|---|
| floor | Round down (toward negative infinity) | 4.7 → 4 |
| ceiling | Round up (toward positive infinity) | 2.3 → 3 |
| toInt | Drop all digits after the decimal point | 7.33 → 7 |
| round | Round to a given precision | 6.56 → 6.5 |