lua-users home
lua-l archive

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




On Monday, December 9, 2013, Philipp Janda wrote:
Am 08.12.2013 19:57 schröbte Philipp Janda:

This looks like there's some truncation to 32 bits going on. Can you
check if recompiling with ´STRUCT_INT` #defined to `ptrdiff_t` solves
the problem (the default `long` still being 32 bits on Windows 64)?


Actually, this seems to be a general problem for integer types larger than `STRUCT_INT`:

    print( -2, tohex( int2str( -2, 16 ) ) )
    print( -2, tohex( struct.pack( '>I16', -2 ) ) )
    print( -2, tohex( struct.pack( '>i16', -2 ) ) )
    print( "2^64", tohex( int2str( 2^64, 16 ) ) )
    print( "2^64", tohex( struct.pack( '>I16', 2^64 ) ) )
    print( "-(2^64)", tohex( int2str( -(2^64), 16 ) ) )
    print( "-(2^64)", tohex( struct.pack( '>I16', -(2^64) ) ) )


-2      FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FE
-2      00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FE
-2      00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FE
2^64    00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00
2^64    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-(2^64) FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00
-(2^64) 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00 00


Philipp


Thank you for looking at this. I haven't been able to check this out further (traveling). As soon as I do, I'll confirm.

-Andrew