UNPKG

1.5 kBMarkdownView Raw
1<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
3# Function floor
4
5Round a value towards minus infinity.
6For matrices, the function is evaluated element wise.
7
8
9## Syntax
10
11```js
12math.floor(x)
13math.floor(x, n)
14```
15
16### Parameters
17
18Parameter | Type | Description
19--------- | ---- | -----------
20`x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Number to be rounded
21`n` | number &#124; BigNumber &#124; Array | Number of decimals Default value: 0.
22
23### Returns
24
25Type | Description
26---- | -----------
27number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Rounded value
28
29
30## Examples
31
32```js
33math.floor(3.2) // returns number 3
34math.floor(3.8) // returns number 3
35math.floor(-4.2) // returns number -5
36math.floor(-4.7) // returns number -5
37
38math.floor(3.212, 2) // returns number 3.21
39math.floor(3.288, 2) // returns number 3.28
40math.floor(-4.212, 2) // returns number -4.22
41math.floor(-4.782, 2) // returns number -4.79
42
43const c = math.complex(3.24, -2.71)
44math.floor(c) // returns Complex 3 - 3i
45math.floor(c, 1) // returns Complex 3.2 - 2.8i
46
47math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
48math.floor([3.21, 3.82, -4.71], 1) // returns Array [3.2, 3.8, -4.8]
49```
50
51
52## See also
53
54[ceil](ceil.md),
55[fix](fix.md),
56[round](round.md)