[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.2 bit32 library incompatibilities with bitlib
- From: Patrick Rapin <toupie300@...>
- Date: Tue, 19 Jun 2012 13:14:35 +0200
I have never used bitlib.
But by looking at its sources, I can see at least the following differences:
- Lua 5.2 bit32 uses unsigned 32-bit integers while bitlib uses
lua_Integer type (signed, 32 or 64-bits).
- There is no "cast" function in bit32, but you can use something like
bit32.bor(x, 0)
- There is no arshift function in bit32 (signed right shift). If you
need it, you will have to write a replacement function.
- In bitlib, you cannot use negative values for displacements in
lshift, rshift and arshift as in bit32.
- Similarly, I expect problems with the shift operations in bitlib if
the displacement is bigger than 31 (since most CPU architectures only
care about least significant bits).
- bit32 has these 6 additional functions compared to bitlib: btest,
extract, replace, lrotate, rrotate.
So Lua 5.2 bit32 has essentially more features than bitlib. When
upgrading from bitlib to bit32, the major problem IMHO would be if you
depend on signed integer arithmetic.