On Mon, 11 Mar 1996, Ben Greear wrote:
>
>
> With respect to unions as bitfields....
>
> I believe a union allocates memory for the LARGEST member of the union,
> so if I understand you correctly, every union you used would have to be of...say long long or whatever....
>
That's correct, the union is allocated enough memory for its
largest member. But I'm not sure if you quite catch what I am proposing:
union bitfield {
struct {
bit1: 1;
bit2: 1;
.
.
bit47: 1;
} bits;
long long value;
}
This way, you can access your bitfield members as
bitfield.bits.bitx, or if you want to compare two complete bitfields, you
can use the | operator on the bitfield.value's.
>
> since you can use the | operator on items in your struct bitfield,
> I am wondering how big you can make them.... for example, how much of
> this would work:
I don't know if you can use the | operator on the individual
members of the struct bitfield. But it's something you can check quickly
by writing a simple program to attempt it, and see if you get the right
answer :)
>
> struct bitfield {
> little_bit: 8;
> bigger_bit: 32;
> rockin_on: 64;
> fat_man: 128;
> MIRV: 1024:
> };//
>
> if you can do this, does the | still work? (I would assume it would, if
> only the first part works!)
>
I don't quite understand what it is you're asking; can you
clarify it?
Graham Gilmore
This archive was generated by hypermail 2b30 : 12/07/00 PST