std.bitarray examples
Janice Caron
caron800 at googlemail.com
Sat May 10 09:24:41 PDT 2008
Here's another possibility you might try:
struct BitFields
{
ubyte n;
uint a() { return (n >> 6) & 3; }
uint b() { return (n >> 4) & 3; }
uint c() { return (n >> 2) & 3; }
uint d() { return (n) & 3; }
void a(uint x) { n &= 0x3F; n |= (x & 3) << 6; }
void b(uint x) { n &= 0xCF; n |= (x & 3) << 4; }
void c(uint x) { n &= 0xF3; n |= (x & 3) << 2; }
void d(uint x) { n &= 0xFC; n |= (x & 3); }
}
Viola. Bitfields in D1.
More information about the Digitalmars-d
mailing list