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 mark.dickinson
Recipients ahrvoje, eric.smith, mark.dickinson
Date 2016-04-17.21:25:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1460928349.55.0.295695042001.issue26785@psf.upfronthosting.co.za>
In-reply-to
Content
About the Python 2.7 behaviour:

>>> from math import copysign
>>> x = float("-nan")
>>> copysign(1.0, x)
1.0

I'd be interested to know what `struct.pack('<d', x)` shows in this case. I'd expect it to be '\x00\x00\x00\x00\x00\x00\xf8\xff', meaning that the `float` conversion has produced a value with its sign bit set, as expected, but `copysign` has failed to transfer that sign bit. That failure is somewhat expected: older versions of MSVC don't provide copysign, so it has to be emulated, and the emulation doesn't take the sign of NaNs into account. (Getting the sign of a NaN is awkward to do without a native copysign function.) It works as expected on OS X and Linux.

So that's a separate issue: copysign on Windows / Python 2.7 doesn't correctly handle the sign bit of a NaN. I agree that that's less than ideal, but I'm not sure whether it's worth fixing for Python 2.7.
History
Date User Action Args
2016-04-17 21:25:49mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, ahrvoje
2016-04-17 21:25:49mark.dickinsonsetmessageid: <1460928349.55.0.295695042001.issue26785@psf.upfronthosting.co.za>
2016-04-17 21:25:49mark.dickinsonlinkissue26785 messages
2016-04-17 21:25:49mark.dickinsoncreate