lua-users home
lua-l archive

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


Duck wrote:
> [snip]
> Under Windows (MinGW 3.x and associated libraries)
> 
> Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>> = 0x12345678
> 305419896
>> - 0x12345678
> stdin:1: unexpected symbol near '-'
>> = -0x12345678
> -305419896
>> = tonumber(-0x12345678)
> -305419896
>> return  tonumber('-0x12345678')
> 39895547400
> 
> The Windows string conversion seems to be "unsigned 32-ing" the converted 
> number, whereas the Linux one is not. I presume the compiler does the 
> negation of hex constants itself, therefore producing consistent results.
> 
> I think it can be considered a bug that (de)hexadecimalisation isn't coded 
> inside Lua itself, making hex and decimal numbers equal-class lexical 
> citizens on all platforms instead of relying on runtime library vagaries.

None of the number conversion is coded within Lua either, so in
order to make guarantees, there has to be an internal strtod()
also. The trouble with msvcrt is that it is frozen in time...

> Is there some luaconf.h finessing I can do to make good under MinGW on 
> Windows? .

It's probably easier to patch luaB_tonumber() with a bit of
platform-specific #ifdef'ed code. It looks like the sign is a
problem only, so handling it shouldn't be too much trouble.

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