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.

classification
Title: math.copysign(1, float('nan'))
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: christian.heimes, mark.dickinson
Priority: normal Keywords:

Created on 2008-05-17 14:39 by christian.heimes, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg66997 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-05-17 14:39
What's your opinion on the edge case

>>> math.copysign(1, float('nan'))
1.0

Is 1.0 the correct answer? IMHO Nan would be better ...
msg66998 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-05-17 14:45
This is fine.  copysign isn't supposed to propagate NaNs---it's just 
supposed to silently transfer the sign bit from the second argument to the 
first.  So I think this is correct behaviour.

Incidentally, on OS X:

>>> from math import copysign
>>> copysign(1, float('nan'))
-1.0

This is also fine, IMO.  It just so happens that on OS X the 'default' NaN 
has its sign bit set.
msg67030 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2008-05-18 16:29
Closing this; I'm 99.72% sure the current behaviour is okay.  :-) 
Christian, please feel free to reopen if you think further discussion is 
needed.
History
Date User Action Args
2022-04-11 14:56:34adminsetgithub: 47149
2008-05-18 16:29:58mark.dickinsonsetstatus: open -> closed
resolution: not a bug
messages: + msg67030
2008-05-17 14:45:18mark.dickinsonsetmessages: + msg66998
2008-05-17 14:39:13christian.heimescreate