Binary Constant Macros in C
Tom Torfs (via Jonathan Rentzsch):
I’ve been missing the lack of support for binary numeric literals in C. To get around it I wrote the following handy macros, which allows you to simply write something like:
whatever = B8(10101010);and will translate as:
whatever = 85;
3 Comments RSS · Twitter
December 12, 2011 8:12 PM
I believe that both gcc and clang support '0b' as a prefix for binary constants.
whatever = 0b10101010;
It's not standard C (or C++), though.