0b
(or 0B
) denotes a binary literal. C++ has allowed it since C++14. (It's not part of the C standard yet although some compilers allow it as an extension.) 0x
(or 0X
) is for hexadecimal.
0
can be used to denote an octal literal. (Interestingly 0
itself is an octal literal). Furthermore you use the escape sequence \
followed by digits to be read in octal: this applies only when defining const char[]
literals using ""
or char
or multicharacter literals using ''
. The '\0'
notation that you often see to denote NUL when working with strings exploits that.
In the absence of a user defined literal suffix, any numeric literal starting with a non-zero is in denary.
There are rumblings in the C++ world to use 0o
for an octal literal and perhaps even drop support for the leading zero version. Although that would be an hideous breaking change.
0
prefix.