interfacing C bitfield structs

Wolfgang Draxinger wdraxinger at darkstargames.de
Mon Mar 20 06:33:23 PST 2006


Don Clugston wrote:

> BITS = (BITS & ~(1<<n)) | (b << n) ;
> to remove the need for a branch instruction.
> Works just as well for multiple bits, eg for b = 0..7:
> BITS = (BITS & ~(7<<n)) | (b << n) ;

Yes, after posting I had the same idea. You see, I'm still
thinking a lot in terms of C/C++ where it isn't gauranteed, that
a boolean value of "true" also is always the LSB==1.

D is just so cool.

-- 
Wolfgang Draxinger




More information about the Digitalmars-d mailing list