Relational Functions (12)

Comparison and equality operations

compare
Compare two values.
Syntax
compare(x | y)
Type Signatures
boolean, boolean, BigNumber, BigNumber, bigint, bigint, Fraction, Fraction, Complex, Complex, number, number
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | Fraction | Unit | string | Array | MatrixFirst value to compare
ynumber | BigNumber | bigint | Fraction | Unit | string | Array | MatrixSecond value to compare
Returns
number | BigNumber | bigint | Fraction | Array | Matrix — Returns the result of the comparison:
Examples
compare(2
3)
compare(3
2)
compare(2
compareNatural
Compare two values of any type in a deterministic, natural way.
Syntax
compareNatural(x | y)
Parameters
NameTypeDescription
x*First value to compare
y*Second value to compare
Returns
number — Returns the result of the comparison:
Examples
compareNatural(2
3)
compareNatural(3
2)
compareNatural(2
compareText
Compare two strings lexically. Comparison is case sensitive.
Syntax
compareText(x | y)
Parameters
NameTypeDescription
xstring | Array | DenseMatrixFirst string to compare
ystring | Array | DenseMatrixSecond string to compare
Returns
number | Array | DenseMatrix — Returns the result of the comparison:
Examples
compareText("B
A")
compareText("A
B")
compareText("A
deepEqual
Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.
Syntax
deepEqual(x | y)
Type Signatures
any, any
Parameters
NameTypeDescription
xnumber | BigNumber | Fraction | Complex | Unit | Array | MatrixFirst matrix to compare
ynumber | BigNumber | Fraction | Complex | Unit | Array | MatrixSecond matrix to compare
Returns
number | BigNumber | Fraction | Complex | Unit | Array | Matrix —
Examples
deepEqual([1
3
4
equal
Check equality of two values. Returns true if the values are equal, and false if not.
Syntax
x == y | equal(x | y)
Type Signatures
any, any
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | boolean | Complex | Unit | string | Array | MatrixFirst value to compare
ynumber | BigNumber | bigint | boolean | Complex | Unit | string | Array | MatrixSecond value to compare
Returns
boolean | Array | Matrix — Returns true when the compared values are equal, else returns false
Examples
2+2 == 3
2+2 == 4
a = 3.2
b = 6-2.8
a == b
equalScalar
Test whether two scalar values are nearly equal.
Type Signatures
boolean, boolean, number, number, BigNumber, BigNumber, bigint, bigint, Fraction, Fraction, Complex, Complex
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | Fraction | boolean | Complex | UnitFirst value to compare
ynumber | BigNumber | bigint | Fraction | boolean | ComplexSecond value to compare
Returns
boolean — Returns true when the compared values are equal, else returns false
equalText
Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.
Syntax
equalText(x | y)
Type Signatures
any, any
Parameters
NameTypeDescription
xstring | Array | DenseMatrixFirst string to compare
ystring | Array | DenseMatrixSecond string to compare
Returns
number | Array | DenseMatrix — Returns true if the values are equal, and false if not.
Examples
equalText("Hello
Hello")
equalText("a
A")
equal("2e3
larger
Check if value x is larger than y. Returns true if x is larger than y, and false if not. Comparing a value with NaN returns false.
Syntax
x > y | larger(x | y)
Type Signatures
Fraction, BigNumber, BigNumber, Fraction, Complex, Complex, number, number
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixFirst value to compare
ynumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixSecond value to compare
Returns
boolean | Array | Matrix — Returns true when the x is larger than y, else returns false
Examples
2 > 3
5 > 2*2
a = 3.3
b = 6-2.8
(a > b)
largerEq
Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.
Syntax
x >= y | largerEq(x | y)
Type Signatures
BigNumber, BigNumber, bigint, bigint, Complex, Complex, number, number
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixFirst value to compare
ynumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixSecond value to compare
Returns
boolean | Array | Matrix — Returns true when the x is larger or equal to y, else returns false
Examples
2 >= 1+1
2 > 1+1
a = 3.2
b = 6-2.8
(a >= b)
smaller
Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not. Comparing a value with NaN returns false.
Syntax
x < y | smaller(x | y)
Type Signatures
Fraction, BigNumber, BigNumber, Fraction, Complex, Complex, number, number
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixFirst value to compare
ynumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixSecond value to compare
Returns
boolean | Array | Matrix — Returns true when the x is smaller than y, else returns false
Examples
2 < 3
5 < 2*2
a = 3.3
b = 6-2.8
(a < b)
smallerEq
Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.
Syntax
x <= y | smallerEq(x | y)
Type Signatures
BigNumber, BigNumber, Complex, Complex, number, number
Parameters
NameTypeDescription
xnumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixFirst value to compare
ynumber | BigNumber | bigint | Fraction | boolean | Unit | string | Array | MatrixSecond value to compare
Returns
boolean | Array | Matrix — Returns true when the x is smaller than y, else returns false
Examples
2 <= 1+1
2 < 1+1
a = 3.2
b = 6-2.8
(a <= b)
unequal
Check unequality of two values. Returns true if the values are unequal, and false if they are equal.
Syntax
x != y | unequal(x | y)
Type Signatures
any, any
Parameters
NameTypeDescription
xnumber | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefinedFirst value to compare
ynumber | BigNumber | Fraction | boolean | Complex | Unit | string | Array | Matrix | undefinedSecond value to compare
Returns
boolean | Array | Matrix — Returns true when the compared values are unequal, else returns false
Examples
2+2 != 3
2+2 != 4
a = 3.2
b = 6-2.8
a != b