lua-users home
lua-l archive

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


On 2010-03-18, David Kastrup <dak@gnu.org> wrote:
> Leo Razoumov <slonik.az@gmail.com> writes:
>
>  > On 2010-03-18, Pan Shi Zhu <pan.shizhu@gmail.com> wrote:
>  >> >>
>  >>
>  >>  According to the manual, %d is defined to deal with 32-bit signed integer.
>  >>
>  >
>  > At present, Lua-5.1.4 manual does *NOT* link %d to 32-bit integers but
>  > think that it should.
>
>
> Since Lua implements its own formatting functions and %d, a 32-bit
>  restriction appears rather out of place.  A major point of Lua's unified
>  number type is that integers are implicitly defined by what fits the
>  mantissa of the underlying floating point type, with "soft" degradation
>  beyond.  That will tend to be something like 53bit or so.  Introducing
>  an additional threshold where things start to go wrong feels artificial.
>

I absolutely agree. But the current implementation of %d does truncate
lua_Number to a 32 bit signed integer and the manual does not warn
about it.

--Leo--