Whether 0 in C ++ is decimal or octal

Source: Internet
Author: User

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 can't 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 over 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, the simple type is actually not simple at all. For more computer problems, go to my 《CodeThe mystery series.

Is 0 an octal number? How are c ++ specifications defined?

Yes. In C ++, 0 is octal.

According to C ++ standards:

2.14.2 integer [Lex. Icon]

Integer-literal:
Decimal-literal integer-suffixopt
Octal-literal integer-suffixopt
Hexadecimal-literal integer-suffixopt
Decimal-literal:
Nonzero-digit
Decimal-literal Digit
Octal-literal:
0 <-------------------- Octal-literal octal-digit

In the future, we can proudly say, "octal in computers is more common than binary or even hexadecimal ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.