概述:
#include <bitset>
int mAIn() {
int b1 = 0b00111011;
}
const int b8 = 0b1111'0000;
const int b16 = 0b1111'0000'1111'0000;
const int b32 = 0b1111'0000'1111'0000'1111'0000'1111'0000;
const int b8 = 0b'1111'0000;
上述代码中的使用方式是错误的,会导致编译错误。
#include <IOStream>
#include <bitset>
int main()
{
int b = 0b00111011;
int b8 = 0b1111'0000;
int b16 = 0b1111'0000'1111'0000;
int b32 = 0b1111'0000'1111'0000'1111'0000'1111'0000;
std::cout << std::bitset<8>(b8) << std::endl;
std::cout << std::bitset<16>(b16) << std::endl;
std::cout << std::bitset<32>(b32) << std::endl;
system("pause");
return 0;
}