lua-users home
lua-l archive

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

On Tue, 20 Jun 2023, Lars Müller wrote:

> You misunderstood the issue: The given number can be represented
> precisely by a 64-bit float. In fact all integers up to and including
> 2^53 can be represented precisely by 64-bit floats. The issue is just
> that conversion to string rounds "too much" by default, losing
> precision. Thus the round-trip tonumber(tostring(x)) == x fails.

...seems the "double" format in luaconf.h does this:
#define LUA_NUMBER_FMT          "%.14g"

...too small to preserve internal precision on print by default.