A binary integer literal is a C23 integer literal written with the prefix 0b or 0B, followed by a sequence containing only 0 and 1 digits. The digits represent a number in base two. section 5.3
A binary value
int mask = 0b1010; /* value: 10 */ int same = 0B1010; /* also value: 10 */ The uppercase B is an alternative spelling of the lowercase b prefix. section 5.3
Key rules:
- Begin the literal with 0b or 0B. section 5.3
- Use only binary digits, 0 and 1, after the prefix. section 5.3
- Treat the literal as an integer constant alongside decimal, octal, and hexadecimal forms. section 5.3
