On Mon, 14 Jun, indifference_engine wrote:
> sbellon;554626 Wrote:
> > What about always ANDing with 1 and shifting the value right
> > successively?
> What? How? Please explain (preferably with some code). It would be
> great to get this little niggle nailed.
I'll try to explain with some meta-code, you may also tell me which Lua
file to look at.
If I understood you correctly, at present you're doing something like
this (this is by no means C code, just C-like!):
for (bit = 0; bit < 32; ++bit)
{
bit_set = value & 2^bit;
}
Then you get 32 times true/false for the bits in value. Did I get that
right? If so, then you can rewrite that into:
copy = value;
for (bit = 0; bit < 32; ++bit)
{
bit_set = copy & 1;
copy = copy >> 1;
}
This should avoid the necessity to AND with a 32-bit top-bit set mask.
--
Stefan Bellon
_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins