#if defined(WIN32)
# include "win32.h"
+# ifdef NAN_COMPARE_BROKEN /* VC6 */
+/* We need to redefine Perl_isinf() because we most likely defined it
+ * using the <DBL_MIN || >DBL_MAX way, which is broken if the NaN
+ * compare is broken. */
+# undef Perl_isinf
+# define Perl_isinf(x) Perl_fp_class_inf(x)
+# endif
#endif
#ifdef NETWARE
return 0;
else {
char* s = buffer;
- /* isnan must be first due to NAN_COMPARE_BROKEN builds, since NAN might
- use the broken for NAN >/< ops in the inf check, and then the inf
- check returns true for NAN on NAN_COMPARE_BROKEN compilers */
- if (Perl_isnan(nv)) {
- *s++ = 'N';
- *s++ = 'a';
- *s++ = 'N';
- /* XXX optionally output the payload mantissa bits as
- * "(unsigned)" (to match the nan("...") C99 function,
- * or maybe as "(0xhhh...)" would make more sense...
- * provide a format string so that the user can decide?
- * NOTE: would affect the maxlen and assert() logic.*/
- }
- else if (Perl_isinf(nv)) {
+ if (Perl_isinf(nv)) {
if (nv < 0) {
if (maxlen < 5) /* "-Inf\0" */
return 0;
*s++ = 'I';
*s++ = 'n';
*s++ = 'f';
+ } else if (Perl_isnan(nv)) {
+ *s++ = 'N';
+ *s++ = 'a';
+ *s++ = 'N';
+ /* XXX optionally output the payload mantissa bits as
+ * "(unsigned)" (to match the nan("...") C99 function,
+ * or maybe as "(0xhhh...)" would make more sense...
+ * provide a format string so that the user can decide?
+ * NOTE: would affect the maxlen and assert() logic.*/
}
else
#define vsnprintf _vsnprintf
#ifdef USING_MSVC6
-/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false */
+/* VC6 has broken NaN semantics: NaN == NaN returns true instead of false,
+ * and for example NaN < IV_MIN. */
#define NAN_COMPARE_BROKEN 1
#endif