Skip to main content

4.5) Comparisons


  • == tests for equality (note the two equals symbols); != tests for inequality
  • <, <=, >, >= behave as they do in other programming languages
  • All of these operators return a bool value (true or false)
  • Comparisons aren't often used on their own; normally they feature in conditional statements (discussed later)
  • Testing floating-point values for equality is not trivial and requires great care, as in most other languages