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;
Related Contents:
- 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]
- How to do serialization of Class having members of custom data types in C++? [closed]
- Converting string of 1s and 0s into binary value
- C++ – Decimal to binary converting
- Why does -INT_MIN = INT_MIN in a signed, two’s complement representation?
- Why Doesn’t reinterpret_cast Force copy_n for Casts between Same-Sized Types?
- What is this weird colon-member (” : “) syntax in the constructor?
- What is the difference between float and double?
- Checking if a double (or float) is NaN in C++
- How to properly add include directories with CMake
- Detecting signed overflow in C/C++
- How to create an std::function from a move-capturing lambda expression?
- Why should one not derive from c++ std string class?
- Static linking vs dynamic linking
- Undefined behavior and sequence points reloaded
- Forward declaration of a typedef in C++
- experimental::filesystem linker error
- Why is out-of-bounds pointer arithmetic undefined behaviour?
- Does C++ limit recursion depth?
- C-Style Strings as template arguments? [duplicate]
- What is string_view?
- What is the default constructor for C++ pointer?
- size of array passed to C++ function? [duplicate]
- Screen recorder [closed]
- What does sizeof do?
- C++11 range based loop: How does it really work
- C++, How to determine if a Windows Process is running?
- Why can’t a derived class call protected member function in this code?
- why can’t we declare object of a class inside the same class?
- How to use OpenSSL’s SHA256 functions
- I cannot pass lambda as std::function
- Custom Iterator in C++
- How is it possible (if it is) to implement shared_ptr without requiring polymorphic classes to have virtual destructor?
- What is the scope of a ‘while’ and ‘for’ loop?
- C++ – Why static member function can’t be created with ‘const’ qualifier
- Why can I access private variables in the copy constructor?
- How do I generate thread-safe uniform random numbers?
- Why do we need to use `int main` and not `void main` in C++? [duplicate]
- How to alpha blend RGBA unsigned byte color fast?
- Defining Global Variables Between Two .cpp Files [duplicate]
- C++ class header files organization
- How to align pointer
- What’s the difference between istringstream, ostringstream and stringstream? / Why not use stringstream in every case?
- C++ priority_queue with lambda comparator error
- how to do an if else depending type of type in c++ template? [duplicate]