[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to get the 2-complenent of a negative number in Lua 5.2?
- From: Niccolo Medici <niccolomedici@...>
- Date: Sun, 3 Jul 2016 20:08:23 +0300
On 7/4/16, Martin <eden_martin_fuhrspam@gmx.de> wrote:
>> unfortunately, in Lua 5.2 it fails:
>>
>> -- Lua 5.2
>> > print(("%x"):format(-123456))
>> stdin:1: bad argument #1 to 'format' (not a non-negative number in
>> proper range)
>>
>> Is there a solution that works in 5.2 as well?
>>
> print(('%x'):format(bit32.band(-2)))
Works perfectly! Thanks.