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