Skip to main content

Comparison Operators

Comparison operators are symbols used to compare two values, known as operands. These operators evaluate to either true or false depending on the relationship between the values. When writing filter expressions, you'll likely need the following four comparison operators:

  • Greater Than (>): This operator checks if the value on the left (LHS) is greater than the value on the right (RHS). For example, 5 > 2 is true because 5 is greater than 2.

  • Greater Than or Equal To (>=): This operator checks if the value on the left is greater than or equal to the value on the right. For example, 5 >= 5 is true because 5 equals 5.

  • Less Than (<): This operator checks if the value on the left is less than the value on the right. For example, 5 < 2 is false because 5 is not less than 2.

  • Less Than or Equal To (<=): This operator checks if the value on the left is less than or equal to the value on the right. For example, 7 <= 3 is false because 7 is neither less than nor equal to 3.

These operators form the core of many logical comparisons and are fundamental to programming and data analysis.

Filter expressions are used to determine whether certain events are kept or discarded based on specific criteria. Here are some examples that use a single comparison operator:

  • Moon.Latitude > 0: This expression results in events being retained when the Moon's latitude is greater than zero at the exact time the event takes place.

  • Moon.Latitude >= Mercury.Latitude: This expression results in events being kept when the Moon's latitude is greater than or equal to Mercury's latitude at the exact time the event takes place.

  • Moon.Distance < 0.0025695: This expression results in events being retained when the distance to the Moon is less than 0.0025695 astronomical units (AU) at the exact time the event takes place.

In each case, the comparison operator helps define the conditions under which an event is retained. If the expression evaluates to false, the event is not included in the results.