On Fri, Nov 09, 2018 at 01:17:09PM -0800, Chris Barker via Python-Dev wrote:
works for me, too:
In [9]: x = cast_int2float(0x7ff8000000000001) In [10]: hex(cast_float2int(x)) Out[10]: '0x7ff8000000000001'
In [11]: x = cast_int2float(0x7ff0000000000001) In [12]: hex(cast_float2int(x)) Out[12]: '0x7ff0000000000001'
Fascinating. I borrowed a Debian system and tried it on there, and got the same results as you. So I wonder whether it is something unusual about my Red Hat system that it prevents the formation of signalling NANs? However, I don't think that explains why the float constructor doesn't allow Decimal('snan') to be converted to a float.
I suspect it depends on the compiler's math library
Unfortunately that's probably true.
But neither is raising an exception: [...] When should it?
I think that, by default, any arithmetic operation, comparison or math library function call ought to raise if given a snan, if the underlying math library supports IEEE-754 signals. Which I imagine these days nearly all should do. So any of these should raise: snan + 1 math.sin(snan) snan == 0 -- Steve