// vc2013_2_P76_5.cpp
//《 Visual c++2013入门经典》(Ivor Horton,7th)
// 2.15练习;P76;练习5编程结果验证
#include <iostream>
#include <bitset>
using std::cout;
using std::endl;
int main()
{
unsigned s{ 555 };
unsigned z{};
int i{ static_cast<int> ((s >> 4) & ~(~0 << 3)) };
cout << "\t555的16进制表示:"<<endl;
cout << std::hex << s << endl<< endl; //555的16进制
cout << "\t555的10进制表示:" << endl;
cout << std::dec << s << endl << endl; //555的10进制
cout << "\t555的2进制表示:" << endl;
cout << std::bitset<16>(555) << endl << endl;
cout << "\t555右移四位的2进制表示:" << endl;
cout << std::bitset<16>(s >> 4) << endl << endl;
cout << "\t0取反再左移三位的2进制表示:" << endl;
cout << std::bitset<16>(~0 << 3) << endl << endl;
cout << "\t对上式0取反的2进制表示:" << endl;
cout << std::bitset<16>(~(~0 << 3)) << endl << endl;
cout << "\t运算结果的的2进制表示:" << endl;
cout << std::bitset<16>((s >> 4) & ~(~0 << 3)) << endl << endl;
cout <<"\t运算结果的的10进制表示:" << endl;
cout <<"The { static_cast<int> ((s >> 4) & ~(~0 << 3))} value of i is\t"<< i<<endl;
return 0; // Exit the program
}