On Tue, Jan 27, 2009 at 10:24:46AM -0800, [email protected] wrote:
> - gen_sprintf_call(tc, &info, ch);
> - ts = cstr2pstr(tc);
> + /* check for Inf and NaN values */
> + if (thefloat == PARROT_FLOATVAL_INF_POSITIVE) {
> + ts = cstr2pstr(PARROT_CSTRING_INF_POSITIVE);
> + }
> + else if (thefloat ==
> PARROT_FLOATVAL_INF_NEGATIVE) {
> + ts = cstr2pstr(PARROT_CSTRING_INF_NEGATIVE);
> + }
> + /* XXX for some reason, this comparison isn't
> working
> + else if (thefloat == PARROT_FLOATVAL_NAN_QUIET) {
No, it is working :-)
NaN != NaN.
Hence why <=> has 4 possible return values.
> + ts = cstr2pstr(PARROT_CSTRING_NAN_QUIET);
> + }
> + */
> + else if (thefloat != thefloat) {
The above is the valid test for a NaN.
Note, Intel chose that the default optimiser setting on their compiler should
be buggy. (Advice from Klortho #11912). The perl 5 Linux hints file suggests
that one needs to add -we147 to enable correct floating point behaviour.
The best test that I'm aware of for "is it NaN or Inf?" is val != val * 0;
Then, NaN is val != val, +Inf is val > 0, -Inf is val < 0;
Nicholas Clark