[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Bitwise XOR in Lua?
- From: Edgar Toernig <froese@...>
- Date: Tue, 10 Sep 2002 16:32:19 +0200
Roberto Ierusalimschy wrote:
> > But de Morganising makes bor use four calls to band (three via bnot), so
> > to avoid that I kept bor primitive.
> You forgot the other "bunny" (whatever that means ;-):
> > not A = -A - 1 (Paul Hsieh wrote that)
> So, you have
> function bor (a,b) return -band(-a-1, -b-1)-1 end
One problem though: -A := not(A)+1 is for 2-complement.
Floating point numbers (normally) do not use 2-complement