#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bool a = 0x03;
bitset<8> x(a);
cout<<x<<endl;
a = a>>1;
bitset<8> y(a);
cout<<y<<endl;
}
The result is:
00000001
00000000
The result is not:
00000011
00000001
If I change the type of a
from bool
to char
, the result will be the second one.
It means that I cannot store more than 0x01 in a bool
, all right value greater than 0x01 are treat as 0x01.
All compiler has the behavior?