lua-users home
lua-l archive

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


Hi All,

I have been reading up on the 'tonumber' function.  From what I can
tell, it doesn't appear to work the way it's documented
(http://pgl.yoyo.org/luai/i/tonumber, my reference)

For example,

[gneill@blackfoot ~]$ cat !$
cat t.lua
print( tonumber( "ff", G))
print( tonumber( "ff", 16))
print( tonumber( "GG", H))
print( tonumber( "GG", 17))

[gneill@blackfoot ~]$ ~/tmp/lua-5.1.4/src/lua < t.lua
nil
255
nil
288

looking at the luaB_tonumber function ...

static int luaB_tonumber (lua_State *L) {
  int base = luaL_optint(L, 2, 10);

luaL_optint returns the default (10) when passed A, B, C ... etc...

Is this a bug? (documentation/code) or am I just not using it correctly?

TIA,
George