lua-users home
lua-l archive

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


> I'm sorry, something has gone wrong with my results:
> 
> $ 32bit/lua -i
> Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> > x=1e16;y=2.9999;print(string.format("%.17g",x+y+y+y))
> 10000000000000012
> 
> $ 64bit/lua -i
> Lua 5.4.0 (work1)  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> > x=1e16;y=2.9999;print(string.format("%.17g",x+y+y+y))
> 10000000000000006
> 

This is as expected, exact value of z = 1e16 + 8.9997
In this case 1 ULP = 2 (that is why all output are even)

32bit/lua round in 64-bits --> +1.50015 ULP against z(exact)
64bit/lua round in 53-bits --> -1.49985 ULP against z(exact)

I don't mind the slightly bad result.
But I like both to return the *same* result.
It is just simple addition, using the same Lua 5.4 work-1