#include <iostream>
int main()
{
int i = 0b0;
std::cout << 0b0 << " ";
std::cout << 0B0 << " ";
std::cout << 0b1010 << " ";
std::cout << 0b00001010 << " ";
std::cout << std::hex << 0b00001010 << " ";
std::cout << std::hex << 0b1111101011111010 << " ";
std::cout << std::hex << 0b11111010111110101111101011111010 << " ";
std::cout << std::hex <<
0b1111101011111010111110101111101011111010111110101111101011111010
<< " ";
std::cout << std::endl;
}
/// Output: 0 0 10 10 a fafa fafafafa fafafafafafafafa
Reference: https://en.wikipedia.org/wiki/C%2B%2B14#Binary_literals
Monday, September 25, 2017
C++14: Binary literals
C++14 added ‘0b’ and ‘0B’ to be a literal prefix that specifies the literal represents a binary number. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment