Well, I did a little test, however it is truncating. But when I assign a value that will fit 4 bits I get some strange numbers. Run this test.
Code:
#include <iostream>
using namespace std;
struct char4 {
char a:4;
char b:4;
};
int main() {
char4 test;
cout<<"sizeof char4: "<<sizeof(char4)<<endl; //1 byte
test.a = 128; // a is truncated to 0 because 128 will not fit in 4 bits
cout<<"a: "<<test.a<<" "<<(unsigned int)test.a<<endl;
test.b = 10; // 10 fits in 4 bits, so b should be 10
cout<<"b: "<<test.b<<" "<<(unsigned int)test.b<<endl; // outputs a very large number that
// would not even fit in a byte.
cout<<"sizeof test: "<<sizeof(test)<<endl; // 1 byte
cin.get();
}
As you can see the 128 is being truncated. Also remember to use unsigned ints, that way the sign bit is treated as part of the number. I'm also getting some strange number for a number like 254.