1 |
|
2 |
|
3 | # Function ceil
|
4 |
|
5 | Round a value towards plus infinity
|
6 | If `x` is complex, both real and imaginary part are rounded towards plus infinity.
|
7 | For matrices, the function is evaluated element wise.
|
8 |
|
9 |
|
10 | ## Syntax
|
11 |
|
12 | ```js
|
13 | math.ceil(x)
|
14 | math.ceil(x, n)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | number | BigNumber | Fraction | Complex | Array | Matrix | Number to be rounded
|
22 | `n` | number | BigNumber | Array | Number of decimals Default value: 0.
|
23 |
|
24 | ### Returns
|
25 |
|
26 | Type | Description
|
27 | ---- | -----------
|
28 | number | BigNumber | Fraction | Complex | Array | Matrix | Rounded value
|
29 |
|
30 |
|
31 | ## Examples
|
32 |
|
33 | ```js
|
34 | math.ceil(3.2) // returns number 4
|
35 | math.ceil(3.8) // returns number 4
|
36 | math.ceil(-4.2) // returns number -4
|
37 | math.ceil(-4.7) // returns number -4
|
38 |
|
39 | math.ceil(3.212, 2) // returns number 3.22
|
40 | math.ceil(3.288, 2) // returns number 3.29
|
41 | math.ceil(-4.212, 2) // returns number -4.21
|
42 | math.ceil(-4.782, 2) // returns number -4.78
|
43 |
|
44 | const c = math.complex(3.24, -2.71)
|
45 | math.ceil(c) // returns Complex 4 - 2i
|
46 | math.ceil(c, 1) // returns Complex 3.3 - 2.7i
|
47 |
|
48 | math.ceil([3.2, 3.8, -4.7]) // returns Array [4, 4, -4]
|
49 | math.ceil([3.21, 3.82, -4.71], 1) // returns Array [3.3, 3.9, -4.7]
|
50 | ```
|
51 |
|
52 |
|
53 | ## See also
|
54 |
|
55 | [floor](floor.md),
|
56 | [fix](fix.md),
|
57 | [round](round.md)
|