lua-users home
lua-l archive

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



On Feb 15, 2016 3:27 AM, "Marc Balmer" <marc@msys.ch> wrote:
>
> When a string is converted to a number using coercion, it is converted to a floating point number, even if it does not contain a decimal point.  When the tonumber() function is used, a string without decimal point is converted to an integer:
>
> Lua 5.3.2  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> > a = 0
> > a = 0 + '1'
> > = a
> 1.0
> > = tonumber('1')
> 1
>
> Is this beviour intended? (and if yes, why?)
>
>

This came up before, actually: http://lua-users.org/lists/lua-l/2015-01/msg00491.html


/s/ Adam