|
Release 4.0 |
|
Comparison Operators
Comparison operators, as their name implies, allow you to compare two values.
|
Example |
Name |
Result |
|
a == b |
Equal |
True if a is equal to b (i.e. has the same value). |
|
a != b |
Not equal |
True if a is not equal to b (i.e. does not have the same value). |
|
a < b |
Less than |
True if a is strictly less than b. |
|
a <= b |
Less than or equal to |
True if a is less than or equal to b. |
|
a > b |
Greater than |
True if a is strictly greater than b. |
|
a >= b |
Greater than or equal to |
True if a is greater than or equal to b. |
|
|
When comparing expressions with different datatypes, remember that
both expressions will be type-casted so they can be compared. For example if you compare a real and a complex number,
then the real number will be type casted to a complex number having an imaginary part of 0.
After that they will be compared. Such type casting can slow down calculations.
|