Is 0 a Decimal or an Octal Literal in C ?
In C , integer literals can be specified in decimal, octal, or hexadecimal formats. Octal literals, once prevalent, have since become less common in modern coding practices. However, a question recently arose regarding zero's literal classification.
Is zero treated as an octal literal under the C grammar? Delving into the C Standard, we find the following definition:
C Standard, Section 2.14.2 Integer Literals:
octal-literal: 0 octal-literal octal-digit
As evident from this excerpt, zero ('0') itself is considered an octal literal. This is because the standard defines an octal literal as a sequence of digits starting with a leading zero. Therefore, zero qualifies as a valid octal literal in C .
The above is the detailed content of Is Zero an Octal Literal in C ?. For more information, please follow other related articles on the PHP Chinese website!