[issue14521] math.copysign(1., float('nan')) returns -1.

Mark Dickinson report at bugs.python.org
Mon Apr 9 18:25:43 CEST 2012


Mark Dickinson <dickinsm at gmail.com> added the comment:

Thanks for the updated patch!  (BTW, you can attach patches as files to the issue rather than writing them inline.)

Yes, this patch is more along the lines that I was thinking of.  There are some issues, though:  (1) we need to deal with endianness issues (including the ARM mixed-endian case).  (2) It looks to me as though the (double *) cast violates strict aliasing rules;  gcc's optimizations can do nasty things in this area.

Rather than reinventing the wheel, we should use the same mechanisms as are already in Python's version of dtoa.c (e.g., see the use of the union to deal with aliasing issues);  we may even be able to steal bits of David Gay's original code directly.

I'll try to find time to look at this in the near future.  I'm still not convinced that anything really needs to change here, though.

I don't understand your comment about pickled objects;  as far as I'm aware there aren't any issues with transferring pickled NaNs from one system to another.

----------
assignee:  -> mark.dickinson
nosy: +eric.smith
priority: normal -> low
stage:  -> needs patch
type: behavior -> enhancement
versions: +Python 3.3 -Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14521>
_______________________________________


More information about the Python-bugs-list mailing list