0是十进制字面量还是八进制字面量? [英] Is 0 a decimal literal or an octal literal?

查看:183
本文介绍了0是十进制字面量还是八进制字面量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

零总是零,所以没关系。但在最近与我的朋友的一次讨论中,他说,八进制文字几乎未被使用。然后它突然出现在我的代码实际上几乎所有的整数文字八进制,即 0

Zero is always zero, so it doesn't matter. But in a recent discussion with my friend he said that octal literals are almost unused today. Then it dawned upon me that actually almost all integer literals in my code are octal, namely 0.

根据C ++语法,是 0 一个八进制文字吗?

Is 0 an octal literal according to the C++ grammar? What does the standard say?

推荐答案

是, 0 strong>八进制文字。

Yes, 0 is an Octal literal in C++.

根据C ++标准:

2.14.2整数文字icon]

2.14.2 Integer literals [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                           <--------------------<Here>
    octal-literal octal-digit

这篇关于0是十进制字面量还是八进制字面量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆