On Aug 21, 2013, at 9:55 AM, erik quanstrom <quans...@quanstro.net> wrote:

> On Wed Aug 21 12:09:26 EDT 2013, 9f...@hamnavoe.com wrote:
>>> at least in terms of passing floating point test suites
>>> (like python's) the NaN issue doesn't come up
>> 
>> Actually it was a test suite that revealed the NaN errors.
>> I wouldn't think it's something anyone needs in normal
>> day-to-day computation, but sometimes boxes must be ticked.
> 
> :-)  it is hard to imagine how this is useful.  it's not like
> ∑{i→∞}-0 is interesting.  at least ∏{i→∞}-0 has an alternating
> sign.  (so does it converge with no limit?)
> 
> the difference i have seen is a situation like
>       atan2(-0, x)    ≡ -π
>       atan2(+0, x)    ≡ pi, ∀ x<0.
> 
> any ideas on how this is useful?


See comments by Stephen Canon in
http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values

Try this:

#include <u.h>
#include <libc.h>

main(){
        double a, b;
        setfcr(0);
        a = 0.0;
        b = a/a;
        if(a <  b) print(" (a <  b)");
        if(a <= b) print(" (a <= b)");
        if(a == b) print(" (a == b)");
        if(a != b) print(" (a != b)");
        if(a >= b) print(" (a >= b)");
        if(a >  b) print(" (a >  b)");
        if(b <  a) print(" (b <  a)");
        if(b <= a) print(" (b <= a)");
        if(b == a) print(" (b == a)");
        if(b != a) print(" (b != a)");
        if(b >= a) print(" (b >= a)");
        if(b >  a) print(" (b >  a)");
        if(b != b) print(" (b != b)");
        if(b == b) print(" (b == b)");
        print("\n");
        return 0;
}

It falsely reports b == b when b is NaN. 

Reply via email to