Floor
Floor
Floor[ expr ] rounds a value down to the nearest integer, or to a given number of decimals.
Usages
Floor[ expr ]
Floor[ expr ] returns the largest integer that is less than or equal to the value of expr. expr can be any expression with a numerical value.
| Example | in | out |
|---|---|---|
Round 1.9 down. |
Floor[ 1.9 ] |
1 |
| For negative numbers, rounding down goes away from zero. | Floor[ -1.1 ] |
-2 |
| A fraction. | Floor[ -3/2 ] |
-2 |
A script variable with value Pi. |
x := Pi |
r = 3 |
Floor[ expr, n ]
Floor[ expr, n ] rounds down to n decimals. A negative n rounds down to tens, hundreds, and so on.
| Example | in | out |
|---|---|---|
Round down to 2 decimals. |
Floor[ 3.14159, 2 ] |
3.14 |
| Round down to hundreds. | Floor[ 1299, -2 ] |
1200 |
Floor[ list ]
If the argument is a list, each element is rounded down.
| Example | in | out |
|---|---|---|
| Round down each element. | Floor[ {1.9, -0.5} ] |
{1, -1} |
Options
OmitTrailingZeroes
If set to False, the result is displayed with exactly n decimals, including zeros at the end. Default: True.
| Syntax | Example | rendered |
|---|---|---|
Floor[ expr, n, OmitTrailingZeroes=>False ] |
Floor[ 3.1, 2, OmitTrailingZeroes=>False ] |
Details
| Invalid input | Result |
|---|---|
Floor[ y ] |
Left unevaluated: the argument must have a numerical value. |
Floor[ 3.1, 1.5 ] |
Error: The second argument of Floor must be an integer, but is 1.5 |