In C ++, is 0 decimal or octal?

Source: Internet
Author: User

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 ".

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.