SyntaxFix
Write A Post
Hire A Developer
Questions
Tags
As we use 0x prefix for hexadecimal numbers, and 0 for octal ones, is there anything that can be done for binary numbers?
0x
0
I tried the b suffix, but the GCC didn't allow it.
b
Error: invalid suffix "b" on integer constant
Is it possible?
This question is related to c
c
Use BOOST_BINARY (Yes, you can use it in C).
#include <boost/utility/binary.hpp> ... int bin = BOOST_BINARY(110101);
This macro is expanded to an octal literal during preprocessing.
Prefix you literal with 0b like in
0b
int i = 0b11111111;
See here.
Source: Stackoverflow.com