Version: v0.8.0 - Beta.  We welcome contributors & feedback.

Number.floor

floor($precision = 0) -> number

Description

Round a fraction down. (i.e. toward negative inifinity)

    <--|                <--|
----+----+----+----+----+----+----+---
   -3   -2   -1    0    1    2    3
$num = 9.99
$num.floor()  //=  9

$num = 3.2
$num.floor()  //=  3

$num = -4.1
$num.floor()  //= -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

Precision 

If $precision is greater than zero, it will return a float with the given number of decimal places.

$num = 9.259
$num.floor(2)  //=  9.25

See Also