Original article: Is
0 a decimal literal or an octal literal?
Translation: C ++
Is 0 decimal or octal?
Translator: justjavac
In C ++, is 0 decimal or octal?
Even in any number of input systems, 0 has only one value, that is, "zero". The reason for asking this question is purely idle.
He recently discussed the topic about data with his friends. He said that eight-digit data has almost never been used. I cannot refute it for a moment. Indeed, apart from the commonly used decimal system, binary and hexadecimal are the most used in the computer, and the octal number is really "niche ".
When I got home, I thought about it. gossip, gossip, "gossip is a number starting with 0." Isn't that 0? 0 is also a number starting with 0! If 0 is octal, we use the octal number almost every day. There are indeed a lot of things worth exploring in the computer. For example, simple types are not simple at all. For more computer problems, you can go to my "puzzle of code" series.
Is 0 an octal number? How are c ++ specifications defined?
Yes. In C ++, 0 isOctal.
According to C ++ standards:
2.14.2 integer [Lex. Icon]
Integer-literal: decimal-literal integer-suffixopt octal-literal integer-suffixopt random-literal integer-suffixopt Decimal-literal: nonzero-digit decimal-literal digit octal-literal: 0 <--------------------
In the future, we can proudly say, "octal in computers is more common than binary or even hexadecimal ".