Starting a numeric literal with 0
means you want it interpreted as octal, which is what I assume you meant when you used "octonary", a word I haven't seen before and, while it appears to be a real word, you'll probably get some blank stares if you use it :-)
This treatment as octal is as per the standard, C++11 2.14.2 Integer literals /1
:
An octal integer literal (base eight) begins with the digit 0 and consists of a sequence of octal digits.
For binary numbers, probably the easiest way to do it is with bit shifting (pre C++14):
uint32_t n1 = 1u << 3;
uint32_t n2 = 1u << 2;
C++14 provides the 0b
prefix, akin to the 0x
one for hexadecimal numbers but I'm not entirely convinced that's as readable as the other option if you still use a large number of leading zeros:
uint32_t n1 = 0b00000000000000000000000000001000;
uint32_t n2 = 0b00000000000000000000000000000100;
Seasoned coders, of course, can instantly map from binary to hex so would probably just use:
uint32_t n1 = 0x00000008;
uint32_t n2 = 0x00000004;