simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

unequal.md (1993B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      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 &#124; BigNumber &#124; Fraction &#124; boolean &#124; Complex &#124; Unit &#124; string &#124; Array &#124; Matrix &#124; undefined | First value to compare
     31 `y` | number &#124; BigNumber &#124; Fraction &#124; boolean &#124; Complex &#124; Unit &#124; string &#124; Array &#124; Matrix &#124; undefined | Second value to compare
     32 
     33 ### Returns
     34 
     35 Type | Description
     36 ---- | -----------
     37 boolean &#124; Array &#124; Matrix | Returns true when the compared values are unequal, else returns false
     38 
     39 
     40 ### Throws
     41 
     42 Type | Description
     43 ---- | -----------
     44 
     45 
     46 ## Examples
     47 
     48 ```js
     49 math.unequal(2 + 2, 3)       // returns true
     50 math.unequal(2 + 2, 4)       // returns false
     51 
     52 const a = math.unit('50 cm')
     53 const b = math.unit('5 m')
     54 math.unequal(a, b)           // returns false
     55 
     56 const c = [2, 5, 1]
     57 const d = [2, 7, 1]
     58 
     59 math.unequal(c, d)           // returns [false, true, false]
     60 math.deepEqual(c, d)         // returns false
     61 
     62 math.unequal(0, null)        // returns true
     63 ```
     64 
     65 
     66 ## See also
     67 
     68 [equal](equal.md),
     69 [deepEqual](deepEqual.md),
     70 [smaller](smaller.md),
     71 [smallerEq](smallerEq.md),
     72 [larger](larger.md),
     73 [largerEq](largerEq.md),
     74 [compare](compare.md)