If you are using GCC then you can use a GCC extension (which is included in the C++14 standard) for this:
int x = 0b00010000;
More Related Contents:
- How do you convert decimal in integer to hexadecimal in integer? [closed]
- Write a c++ function that will prompt a user for an integer and convert it to binary and print in reverse order [duplicate]
- Explanation of shift operationals use in condition
- Leading zeros of a binary number doesn’t get printed
- Reading and writing binary file
- How to print (using cout) a number in binary form?
- Is it safe to use -1 to set all bits to true?
- Read binary data from std::cin
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- How to reverse an std::string? [duplicate]
- Why does -INT_MIN = INT_MIN in a signed, two’s complement representation?
- C++ – Decimal to binary converting
- How to do serialization of Class having members of custom data types in C++? [closed]
- Converting string of 1s and 0s into binary value
- Efficient bitwise operations for counting bits or find the right|left most ones
- Fastest way to Convert String to Binary?
- Difference between opening a file in binary vs text [duplicate]
- Why Doesn’t reinterpret_cast Force copy_n for Casts between Same-Sized Types?
- Can I list-initialize a vector of move-only type?
- Why is ‘this’ a pointer and not a reference?
- Why are strings in C++ usually terminated with ‘\0’?
- Compile time triggered range check for std::vector
- Why do we require requires requires?
- Passing array of structures to function c++
- is it ok to specialize std::numeric_limits for user-defined number-like classes?
- Object oriented programming in Haskell
- Why does unique_ptr take two template parameters when shared_ptr only takes one?
- How to convert a time into epoch time?
- C++ Win32 keyboard events
- Does the C++ standard specify anything on the representation of floating point numbers?