lua-users home
lua-l archive

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


On 15 July 2015 at 10:58, Rena <hyperhacker@gmail.com> wrote:
> This is something I've been stubbing my toe on a lot lately and it's
> rather annoying:
>
> Lua 5.3.1  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> ; print(string.format('%d', 1.1))
> stdin:1: bad argument #2 to 'format' (number has no integer representation)
> stack traceback:
>     [C]: in function 'string.format'
>     stdin:1: in main chunk
>     [C]: in ?
> ;
>
> In previous versions - and in C - it would just silently truncate the
> number (drop the fractional part). Why was this changed?

Truncation is undefined and a surprising source of errors.
See the subthread starting at
http://lua-users.org/lists/lua-l/2014-12/msg00259.html