On Tue, Jul 14, 2020 at 3:51 PM Roberto Ierusalimschy wrote:
This is something from the hardware. If you do that in C, which
generates the obvious machine code, it results in -nan too.
C runtime library may mask the difference between HW results when converting nan to string:
Lua on Linux
> math.log(-1)
nan
> math.sqrt(-1)
-nan
> string.pack("d",math.log(-1)):byte(1,-1)
0 0 0 0 0 0 248 127
> string.pack("d",math.sqrt(-1)):byte(1,-1)
0 0 0 0 0 0 248 255
Lua on Windows (MinGW)
> math.log(-1)
nan
> math.sqrt(-1)
nan
> string.pack("d",math.log(-1)):byte(1,-1)
0 0 0 0 0 0 248 127
> string.pack("d",math.sqrt(-1)):byte(1,-1)
0 0 0 0 0 0 248 255