Home > Backend Development > C++ > body text

Is Zero an Octal Literal in C ?

Susan Sarandon
Release: 2024-11-26 08:46:12
Original
713 people have browsed it

Is Zero an Octal Literal in C  ?

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
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template