1 |
|
2 |
|
3 | # Function isZero
|
4 |
|
5 | Test whether a value is zero.
|
6 | The function can check for zero for types `number`, `BigNumber`, `Fraction`,
|
7 | `Complex`, and `Unit`.
|
8 |
|
9 | The function is evaluated element-wise in case of Array or Matrix input.
|
10 |
|
11 |
|
12 | ## Syntax
|
13 |
|
14 | ```js
|
15 | math.isZero(x)
|
16 | ```
|
17 |
|
18 | ### Parameters
|
19 |
|
20 | Parameter | Type | Description
|
21 | --------- | ---- | -----------
|
22 | `x` | number | BigNumber | Complex | Fraction | Unit | Array | Matrix | Value to be tested
|
23 |
|
24 | ### Returns
|
25 |
|
26 | Type | Description
|
27 | ---- | -----------
|
28 | boolean | Returns true when `x` is zero. Throws an error in case of an unknown data type.
|
29 |
|
30 |
|
31 | ## Examples
|
32 |
|
33 | ```js
|
34 | math.isZero(0) // returns true
|
35 | math.isZero(2) // returns false
|
36 | math.isZero(0.5) // returns false
|
37 | math.isZero(math.bignumber(0)) // returns true
|
38 | math.isZero(math.fraction(0)) // returns true
|
39 | math.isZero(math.fraction(1,3)) // returns false
|
40 | math.isZero(math.complex('2 - 4i') // returns false
|
41 | math.isZero(math.complex('0i') // returns true
|
42 | math.isZero('0') // returns true
|
43 | math.isZero('2') // returns false
|
44 | math.isZero([2, 0, -3]') // returns [false, true, false]
|
45 | ```
|
46 |
|
47 |
|
48 | ## See also
|
49 |
|
50 | [isNumeric](isNumeric.md),
|
51 | [isPositive](isPositive.md),
|
52 | [isNegative](isNegative.md),
|
53 | [isInteger](isInteger.md)
|