1.50. Floating matches

Felix provides special matching for floating point. Here are some examples: [This will change, the need for overlapping ranges is too ugly ..]
Start felix section to tut/examples/tut_beg160.flx[1 /1 ]
     1: #line 2752 "./lpsrc/flx_tutorial.pak"
     2: #import <flx.flxh>
     3: 
     4: match (1.0) with
     5:   | NaN => { print "Not a Number"; }
     6:   | -inf .. -0.999 => { print "lt -1"; }
     7:   | -1.001 .. 1.001 => { print "Unit circle"; }
     8:   | 0.999 .. inf => { print "Greater than 1"; }
     9: endmatch;
    10: endl;
    11: 
    12: match (1.0) with
    13:   | 0.999 .. 1.001 => { print "one"; }
    14: endmatch;
    15: endl;
    16: 
    17: match (1.0/3.0) with
    18:  | 0.3333 .. 0.3334 => { print "One third"; }
    19: endmatch;
    20: endl;
    21: 
End felix section to tut/examples/tut_beg160.flx[1]
Things to note are: if there is NaN test, it must be the first test. If there is a test -inf .. inf, it tests for a non-NaN, and must be the last test. A NaN will fail all tests other than a test for NaN.

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?]