1: include "std"; 2: 3: match (1.0) with 4: | NaN => { print "Not a Number"; } 5: | -inf .. -0.999 => { print "lt -1"; } 6: | -1.001 .. 1.001 => { print "Unit circle"; } 7: | 0.999 .. inf => { print "Greater than 1"; } 8: endmatch; 9: endl; 10: 11: match (1.0) with 12: | 0.999 .. 1.001 => { print "one"; } 13: endmatch; 14: endl; 15: 16: match (1.0/3.0) with 17: | 0.3333 .. 0.3334 => { print "One third"; } 18: endmatch; 19: endl; 20:
A range test is neither inclusive nor exclusive! That's why there is no test for a particular float, and why the ranges above overlap. Welcome to constructive mathematics!
Note that _floating_ point provides exact comparisons, however, the patterns above apply to constructive reals. The last example explains this best: you can't do non-constructive matches. [Use IEEE type for exact FP?]