lua-users home
lua-l archive

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


Hi all,

Andreas Stenius wrote:
D Burgess skrev:
[snip]
lua_number2int

If you have lrint() use it.

while you are at it, check on.

lua_str2number(s,p)

DB

Thanks, I've looked at it. But I can't see how this can be from a bad setup in luaconf.
Since the and/or construct works when used with variable lookups, example:

 > =false or 1
1.0890312344636e-60
 > i = 1
 > =i
1
 > =false or i
1
 >

Your sample:

  local a = true and 0

on Lua 5.1/cygwin gives 0. It compiles to:

[1] loadk      0   0        ; 0
[2] return     0   1

But on your platform, 1.0890312344636e-60 is however, E0FFFFFF05007C33 hex, and the first 4 bytes looks *very* suspicious to me.

But:

  local a = true or 0

is not optimized to a LOADK. It compiles to:

[1] jmp        3            ; to [5]
[2] loadk      0   0        ; 0
[3] jmp        2            ; to [6]
[4] loadbool   0   0   1    ; false, to [6]
[5] loadbool   0   1   0    ; true
[6] return     0   1

Looks like some kind of optimization thingy barfed on you. :-)

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia