【发布时间】:2012-07-25 17:18:22
【问题描述】:
int main()
{
cout << hex;
cout << (0xe & 0x3); // 1110 & 0011 -> 0010 (AND)
cout << endl;
cout << (0xe | 0x3); // 1110 | 0011 -> 1111 (OR)
cout << endl;
cout << (0xe ^ 0x3); // 1110 ^ 0011 -> 1101 (XOR)
return 0;
}
使用 cout 时,它显示转换(2、f 和 d)与实际值(0010、1111 和 1101)。我怎样才能让它显示这个与位的内容?
【问题讨论】:
标签: c++ binary hex iostream cout