Bill Coffman wrote: > NegNan doesn't exist, except as a fluke of the representation (see link for > how they are represented). A -NaN is the same as a NaN. They both fail > all > comparison tests, even NaN == NaN is false (unless your compiler optimizes > the comparison out). Only difference is the way they are stringified, > which > should be "NaN", but stringification of NaN is non-standard. Solaris > compilers will print "-NaN", but gcc only prints "nan". Microsoft compiler > prints strange stuff.
I am wondering if this NaN != NaN property could be used for the isnan and finite tests, like so: int Parrot_math_isnan(double x) { return x != x; } int Parrot_math_finite(double x) { return (!Parrot_math_isnan(x - x)); } That is, if "x != x" it's a NaN. If x is finite, "x - x" should yield something close to 0. Otherwise, "Inf - Inf" or "NaN - NaN", it's NaN. Is this not portable enough? Is it better to look at the bits directly? Ron