lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Am 06.10.2016 um 15:48 schrieb Karol Drożak:
Hi all,

I have a problem with bytecode execution on QNX, which was created on Windows.
Test program:

# cat tonumber.lua
print (1.3e-2, tonumber(' 1.3e-2 '), 1.3e-2 == tonumber(' 1.3e-2 '))


Why the value are not equal?
Bytecodes seem to be the same.

I compared bytecode files between platforms.
Diff gives that:

# xxd qnx_tonumber.luac51 > qnx_tonumber.luac51.hex
# xxd qnx_tonumber.luac53 > qnx_tonumber.luac53.hex
# xxd win_tonumber.luac51 > win_tonumber.luac51.hex
# xxd win_tonumber.luac53 > win_tonumber.luac53.hex
# diff qnx_tonumber.luac51.hex win_tonumber.luac51.hex
8c8
< 0000070: 7269 6e74 0003 3ab4 c876 be9f 8a3f 0409  rint..:..v...?..
---
> 0000070: 7269 6e74 0003 39b4 c876 be9f 8a3f 0409  rint..9..v...?..
# diff qnx_tonumber.luac53.hex win_tonumber.luac53.hex
9c9
< 0000080: 6e74 033a b4c8 76be 9f8a 3f04 0974 6f6e  nt.:..v...?..ton
---
> 0000080: 6e74 0339 b4c8 76be 9f8a 3f04 0974 6f6e  nt.9..v...?..ton


The diff should have pointed it out: it's the place where the binary floating-points
are stored. the byte sequence
39b4c876be9f8a3f is the  double (64bit) IEEE754 format of 0.013 not rounded, i.e.
3ab4c876be9f8a3f is the same ting rounded. the diff is inthe lest significiant bits:
 *-here

The incompatibility is in the handling of floating point conversion on both systems.

--
Oliver