==
Equality operator.
Syntax
expr_1 == expr_2
Operands
- expr_1, expr_2
- A pair of valid scalar expressions.
Example
Expression | Result |
---|---|
0 == 3
|
0 |
0 == sin(0)
|
1 |
1 == {1, 2, 3}
|
0 |
{1, 2, 3} == {4, 5, 6}
|
0 |
{1, 2, 3} == ( {4, 5, 6} - 3)
|
1 |
{ {1, 2}, {3, 4} } == {1, 2, 3, 4}
|
0 |
{ {1, 0}, {0, 4} } == ( { {1, 0}, {0, 2} }
^2)
|
1 |
"hello" == "goodbye"
|
0 |
"abcd" == "ab" + "cd"
|
1 |
{"abc", "def"} == "abc"
|
0 |
Comments
The equality operator compares two expressions to determine if they are the same type, have the same dimensions, and contain the same values.
If expr_1 and expr_2 are equal, the result is one.
If expr_1 and expr_2 are not equal, the result is zero.
If expr_1 and expr_2 are of different types, they are unequal and the result is zero.
If they are the same type: i.e., both are vectors, but have different dimensions, they are unequal and the result is zero.
If they are of the same type with the same dimensions, but not all elements are equal, they are unequal and the result is zero.
Some operating systems introduce round-off errors that can produce erroneous results. For instance, the calculated value of sqrt(25) and 5 might not be equal if the operating system evaluates the value of sqrt(25) to be 5.0000001.