[Python-Dev] Signalling NANs

2018-11-09 Thread Steven D'Aprano
I'm trying to understand some unexpected behaviour with float NANs in Python 3.5. Background: in IEEE-754 maths, NANs (Not A Number) come in two flavours, so called "quiet NANs" and "signalling NANs". By default, arithmetic operations on qnans return a qnan; operations on snans "signal", which

Re: [Python-Dev] Signalling NANs

2018-11-09 Thread Serhiy Storchaka
09.11.18 13:05, Steven D'Aprano пише: py> x = cast_int2float(0x7ff1) py> x nan py> hex(cast_float2int(x)) '0x7ff80001' I got '0x7ff1'. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/l

Re: [Python-Dev] Signalling NANs

2018-11-09 Thread Chris Barker via Python-Dev
works for me, too: In [9]: x = cast_int2float(0x7ff80001) In [10]: hex(cast_float2int(x)) Out[10]: '0x7ff80001' In [11]: x = cast_int2float(0x7ff1) In [12]: hex(cast_float2int(x)) Out[12]: '0x7ff1' OS-X, conda build: Python 3.7.0 | packaged by conda-forge

Re: [Python-Dev] Signalling NANs

2018-11-10 Thread Steven D'Aprano
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(0x7ff80001) > In [10]: hex(cast_float2int(x)) > Out[10]: '0x7ff80001' > > In [11]: x = cast_int2float(0x7ff1) > In [12]: hex(cast_float2int(

Re: [Python-Dev] Signalling NANs

2018-11-10 Thread Nathaniel Smith
On Sat, Nov 10, 2018 at 3:26 PM, Steven D'Aprano wrote: > 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(0x7ff80001) >> In [10]: hex(cast_float2int(x)) >> Out[10]: '0x7ff80001' >> >> In [11]: x = c

Re: [Python-Dev] Signalling NANs

2018-11-11 Thread Steven D'Aprano
On Sat, Nov 10, 2018 at 04:27:29PM -0800, Nathaniel Smith wrote: > Apparently loading a sNaN into an x87 register silently converts it to > a qNaN, and on Linux C compilers are allowed to do that at any point: > > > https://stackoverflow.com/questions/22816095/signalling-nan-was-corrupted-whe

Re: [Python-Dev] Signalling NANs

2018-11-11 Thread Greg Ewing
Steven D'Aprano wrote: The Debian box uses an ARM processor, so there's that difference too. FWIW, I tried this on MacOSX 10.6 with an Intel Xeon and it also seems to suppress sNaNs. -- Greg ___ Python-Dev mailing list Python-Dev@python.org https://