lua-users home
lua-l archive

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


On Mon, Aug 10, 2009 at 10:26 PM, Sam Roberts<vieuxtech@gmail.com> wrote:
> On Mon, Aug 10, 2009 at 7:38 PM, George Neill<georgen@neillnet.com> wrote:
>> [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...
>
> No, A, B, C are names of undefined variables, so you are passing nil
> as the second argument. Passing nil causes the default to be used.

Makes complete sense.  Is it possible to pass A-Z as the documentation suggests?

TIA,
George