sbellon;554643 Wrote: 
> 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!):
> > 
Code:
--------------------
  >   > 
  > 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:
> > 
Code:
--------------------
  >   > 
  > 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.
That looks promising it looks like instead of moving the set-bit of the
mask you move the value, obvious really but I didn't know it could be
done.  I'll give it a go.  The other solution I was thinking of was
converting the value to binary abd then to a string so that I could
walk along it testing each character using string functions.  Your
solution looks neater (assuming lua can deal with bit-shifting).  The
function in question is DecToBin() in lirc.lua.


-- 
indifference_engine
------------------------------------------------------------------------
indifference_engine's Profile: 
http://forums.slimdevices.com/member.php?userid=20698
View this thread: http://forums.slimdevices.com/showthread.php?t=79524

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to