1 |
|
2 |
|
3 | # Function fix
|
4 |
|
5 | Round a value towards zero.
|
6 | For matrices, the function is evaluated element wise.
|
7 |
|
8 |
|
9 | ## Syntax
|
10 |
|
11 | ```js
|
12 | math.fix(x)
|
13 | ```
|
14 |
|
15 | ### Parameters
|
16 |
|
17 | Parameter | Type | Description
|
18 | --------- | ---- | -----------
|
19 | `x` | number | BigNumber | Fraction | Complex | Array | Matrix | Number to be rounded
|
20 |
|
21 | ### Returns
|
22 |
|
23 | Type | Description
|
24 | ---- | -----------
|
25 | number | BigNumber | Fraction | Complex | Array | Matrix | Rounded value
|
26 |
|
27 |
|
28 | ## Examples
|
29 |
|
30 | ```js
|
31 | math.fix(3.2) // returns number 3
|
32 | math.fix(3.8) // returns number 3
|
33 | math.fix(-4.2) // returns number -4
|
34 | math.fix(-4.7) // returns number -4
|
35 |
|
36 | const c = math.complex(3.2, -2.7)
|
37 | math.fix(c) // returns Complex 3 - 2i
|
38 |
|
39 | math.fix([3.2, 3.8, -4.7]) // returns Array [3, 3, -4]
|
40 | ```
|
41 |
|
42 |
|
43 | ## See also
|
44 |
|
45 | [ceil](ceil.md),
|
46 | [floor](floor.md),
|
47 | [round](round.md)
|