Lesson Summary

This lesson introduced the concept of comparison operators, which are used to compare the value of two operands and return a Boolean value of either True or False depending on whether the operator’s conditions are satisfied (Or – if the expression cannot be evaluated – Null).

Although they are traditionally used for comparing the value of two numeric operands, you can also use these operators to compare text-based values, which they do by comparing the sort order of the text characters from left to right.

Comparing one value to another is the foundation of conditional logic, allowing you to construct dynamic expressions that depend on values meeting the criteria you specify. This lesson taught you the six primary comparison operators, explaining the conditions needed to satisfy them and why you might need to use them:

  • Equality: If the values of the two operands are the same, returns True. Otherwise, it returns False.
  • Not Equals: The inverse of Equality, this operator returns True if the values of its two operands differ in any way.
  • Less Than: Returns True if the value of the first operand is lower than the value of the second operand, and False otherwise.
  • Greater Than: Returns True if the value of the first operand is more than the value of the second operand, and False otherwise.
  • Less Than or Equal To: The inverse of Greater Than, this operator returns True if the value of the first operand is lower than the second, or if the two are the same. If the first value is greater than the second, the operator returns False.
  • Greater Than or Equal To: The inverse of Less Than, this operator returns True if the value of the first operand is higher than the second, or if the two are the same. If the first value is lower than the second, the operator returns False.

You should now be comfortable enough with the meaning, syntax and use of these six operators to construct expressions using one or more of them. You should also understand how the comparison operators work using both numeric and text values.

 

<< Previous: Comparison Operator Precedence | Next: Test Your Knowledge! >>