cintegerconstantszero

Why Zero has no decimal integer spelling in C?


I am reading modern C, and on page 66, I come across following section:

Remember that value 0 is important. It is so important that it has a lot of equivalent spellings: 0, 0x0, and ’\0’ are all the same value, a 0 of type signed int. Zero has no decimal integer spelling: 0.0 is a decimal spelling for the value 0 but is seen as a floating-point value with type double.

I am a little confused, why "Zero has no decimal integer spelling"? Isn't 0 decimal integer spelling?


Solution

  • "Spelling" is a strange term to use in this context; "source code representation" is a better if less succinct term perhaps, or just "representation" in context. But specifically regarding the part:

    Zero has no decimal integer spelling

    the point is that in C an integer literal prefixed with a zero is an octal value, not a decimal value. It is kind of a pedantic point that need not be highlighted perhaps, but it is mentioned a few pages earlier in the text:

    enter image description here