[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Bitwsie operators in Lua
- From: David Jones <drj@...>
- Date: Mon, 19 Jun 2006 14:08:34 +0100
David Jones wrote:
Roberto Ierusalimschy wrote:
Essentially any bitwise operation gets converted to a series
That is all we wanted for Lua. But "not" and shifts are easy. Can you
give a viable implementation for or/and?
Well, I was talking about specifying the meaning. As for an
implementation, choose the simple portable approach: convert the
number to your favourite, C, integer type, do the operation in that
type, then convert back to whatever type you've chosen for numbers.
Sticking to double (for numbers) and int (for integers) and doing this
gives you a portable 32-bit implementation. luaconf.h helps those who
Or were you thinking of an approach where you change only the compiler
and not the VM? You can't reasonably do that, the implementation of
"bitwise-and" is too tedious. However with just "bitwise-and" or
"bitwise-or" you can do all the others.