1 |
|
2 |
|
3 | # Function unequal
|
4 |
|
5 | Test whether two values are unequal.
|
6 |
|
7 | The function tests whether the relative difference between x and y is
|
8 | larger than the configured epsilon. The function cannot be used to compare
|
9 | values smaller than approximately 2.22e-16.
|
10 |
|
11 | For matrices, the function is evaluated element wise.
|
12 | In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im.
|
13 | Strings are compared by their numerical value.
|
14 |
|
15 | Values `null` and `undefined` are compared strictly, thus `null` is unequal
|
16 | with everything except `null`, and `undefined` is unequal with everything
|
17 | except `undefined`.
|
18 |
|
19 |
|
20 | ## Syntax
|
21 |
|
22 | ```js
|
23 | math.unequal(x, y)
|
24 | ```
|
25 |
|
26 | ### Parameters
|
27 |
|
28 | Parameter | Type | Description
|
29 | --------- | ---- | -----------
|
30 | `x` | number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined | First value to compare
|
31 | `y` | number | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefined | Second value to compare
|
32 |
|
33 | ### Returns
|
34 |
|
35 | Type | Description
|
36 | ---- | -----------
|
37 | boolean | Array | Matrix | Returns true when the compared values are unequal, else returns false
|
38 |
|
39 |
|
40 | ## Examples
|
41 |
|
42 | ```js
|
43 | math.unequal(2 + 2, 3) // returns true
|
44 | math.unequal(2 + 2, 4) // returns false
|
45 |
|
46 | const a = math.unit('50 cm')
|
47 | const b = math.unit('5 m')
|
48 | math.unequal(a, b) // returns false
|
49 |
|
50 | const c = [2, 5, 1]
|
51 | const d = [2, 7, 1]
|
52 |
|
53 | math.unequal(c, d) // returns [false, true, false]
|
54 | math.deepEqual(c, d) // returns false
|
55 |
|
56 | math.unequal(0, null) // returns true
|
57 | ```
|
58 |
|
59 |
|
60 | ## See also
|
61 |
|
62 | [equal](equal.md),
|
63 | [deepEqual](deepEqual.md),
|
64 | [smaller](smaller.md),
|
65 | [smallerEq](smallerEq.md),
|
66 | [larger](larger.md),
|
67 | [largerEq](largerEq.md),
|
68 | [compare](compare.md)
|