Nicholas Clark
2009-01-27 18:58:43 UTC
- 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 :-)- 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) {
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.+ }
+ */
+ else if (thefloat != thefloat) {
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