lua-users home
lua-l archive

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


It was thus said that the Great Soni L. once stated:
> 
> >   You misunderstood me.
> >
> >	tonumber() always returns a double or nil if not a double
> >	math.tointeger() always returns an integer or nil if not an integer
> >
> >tonumber() isn't smart.  math.tointeger() isn't smart.
> >
> You mean using strings with math.tointeger()?
> 
> If that's the case, I think we should have math.tointeger() and 
> math.tofloat(), and tonumber() should be smart. For backwards 
> compatibility, too.

It already supports strings:

[spc]lucy:~>lua-53
Lua 5.3.2  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> x = math.tointeger("12345") print(x)
12345
> 

  -spc