Programmers often need to talk about ranges of values (whether or not the language at hand supports the concept explicitly). For example, given the Java array
String streetLines = new String;
i must satisfy
i< 3 (in normal Mathematical notation)
0 <= i && i < 3(in Java notation)
to be a valid index on
streetLines. But how does one read those expressions aloud?
I learned to read
≤ as “at most” and
≥ as “at least” from Dijkstra. Those readings have at least two benefits:
- They are quite natural. For example, the assertion
there are at least six eggs left in the carton
is at least as obvious in normal speech as the equivalent phrase
there are six or more eggs in the carton
and is probably much more obvous than other equivalent phrases, such as
the number of eggs left in the carton is greater than or equal to six
there are more than five eggs left in the carton
even though we’ve seen the equivalent of those in code many times.
- They avoid introducing extraneous logical operators. The phrasing
less than or equal to
seems more complex than
because it implies the use of disjunction (logical “or“) in its evaluation. The other equivalent phrase
not greater than
introduces negation into a simple comparison.
As a tiny “easter egg”, look for uses of “at least” en passant in the preceding few sentences! If they went by without being obvious, perhaps that serves as evidence of point 1 above.