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'

OS-X, conda build:

Python 3.7.0 | packaged by conda-forge | (default, Aug 27 2018, 17:24:52)
[Clang 6.1.0 (clang-602.0.53)] on darwin

I suspect it depends on the compiler's math library

But neither is raising an exception:

In [3]: x = cast_int2float(0x7ff0000000000001)

In [4]: y = cast_int2float(0x7ff8000000000001)

In [5]: 2.0 / x
Out[5]: nan

In [6]: 2.0 / y
Out[6]: nan

When should it?

-CHB



On Fri, Nov 9, 2018 at 3:46 AM, Serhiy Storchaka <storchaka@gmail.com> wrote:
09.11.18 13:05, Steven D'Aprano пише:
py> x = cast_int2float(0x7ff0000000000001)
py> x
nan
py> hex(cast_float2int(x))
'0x7ff8000000000001'

I got '0x7ff0000000000001'.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov