homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mattip
Recipients loewis, mark.dickinson, mattip
Date 2012年04月08日.19:25:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333913110.63.0.416452500717.issue14521@psf.upfronthosting.co.za>
In-reply-to
Content
You are correct, the patch should use fabs
I would go with a standard, cross-platform definition of Py_NAN so that pickled objects could be opened by other platforms. Would this patch be better? It's more complicated as I needed to cast the repr of Py_NAN to a unsigned char[]. It passes the tests in test.test_math and handles the copysign in a more intuitive way
>>> math.copysign(1., float('nan')) => 1. on win32, microsoft compiler
diff -r efeca6ff2751 Include/pymath.h
--- a/Include/pymath.h Thu Apr 05 22:51:00 2012 +0200
+++ b/Include/pymath.h Sun Apr 08 22:20:16 2012 +0300
@@ -152,8 +152,13 @@
 * doesn't support NaNs.
 */
 #if !defined(Py_NAN) && !defined(Py_NO_NAN)
+#if DBL_MANT_DIG == 53 /* ieee 754 doubles */
+extern double * _Py_NAN;
+#define Py_NAN (*_Py_NAN)
+#else
 #define Py_NAN (Py_HUGE_VAL * 0.)
 #endif
+#endif
 /* Py_OVERFLOWED(X)
 * Return 1 iff a libm function overflowed. Set errno to 0 before calling
diff -r efeca6ff2751 Modules/_math.c
--- a/Modules/_math.c Thu Apr 05 22:51:00 2012 +0200
+++ b/Modules/_math.c Sun Apr 08 22:20:16 2012 +0300
@@ -24,6 +24,10 @@
 static const double two_pow_p28 = 268435456.0; /* 2**28 */
 static const double zero = 0.0;
+#if DBL_MANT_DIG == 53 /* ieee 754 doubles */
+static const unsigned char _Py_NAN_as_char[8] = {0, 0, 0, 0, 0, 0, 0xf8, 0x7f};
+extern double * _Py_NAN = (double *)(_Py_NAN_as_char);
+#endif
 /* acosh(x)
 * Method :
 * Based on
History
Date User Action Args
2012年04月08日 19:25:10mattipsetrecipients: + mattip, loewis, mark.dickinson
2012年04月08日 19:25:10mattipsetmessageid: <1333913110.63.0.416452500717.issue14521@psf.upfronthosting.co.za>
2012年04月08日 19:25:10mattiplinkissue14521 messages
2012年04月08日 19:25:09mattipcreate

AltStyle によって変換されたページ (->オリジナル) /