Binary Literals - C++ Data Type

C++ examples for Data Type:Binary

Introduction

You create a binary integer literal as binary digits (0 or 1) prefixed by 0b or 0B.

A binary literal can have L or LL as a suffix to indicate it is type long or long long, and u or U if it is an unsigned literal. For example:

0B110101111      0b100100011U         0b1010L  0B11001101         0b11111111

Demo Code

#include <iostream>

int main()/*from  w  w  w .  j av  a  2  s .  c  o  m*/
{
    int color {0b000011110000110100001110};

    std::cout << "The value of color is "  << color  << std::endl;
}

Result


Related Tutorials