0是一个八进制或在C小数? [英] Is 0 an octal or a decimal in C?

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

问题描述

我读<一个href=\"http://stackoverflow.com/questions/6895522/is-0-a-decimal-literal-or-an-octal-literal\">this.这是C ++和小数在Java中八进制。但是,没有关于C的描述?

I have read this. It's octal in C++ and decimal in Java. But no description about C?

这是否作出任何区别,如果是0八进制或十进制?这是我的面试官提出的问题。我说没有,我解释说,它始终是0无论是八进制或十进制。

Is it going to make any difference if 0 is octal or decimal? This is the question asked by my interviewer. I said no and I explained that it is always 0 regardless whether it is octal or decimal.

然后他问为什么它认为在C ++八进制和十进制在Java中。我说这是标准的。请让我知道什么是在C?会不会有什么区别?为什么他们在不同的标准有什么不同?

Then he asked why is it considered as octal in C++ and decimal in Java. I said it's the standard. Please let me know what is it in C? Will it make any difference? Why are they different in different standards?

推荐答案

这使得差别不大,但正式的整型常量 0 是八进制C.从C99和C11标准, 6.4.4.1整型常量

It makes little difference, but formally the integer constant 0 is octal in C. From the C99 and C11 standards, 6.4.4.1 Integer constants

整型常量的:结果
  &NBSP;&NBSP;&NBSP;&NBSP;的十进制常数整数后缀<子>选择 的结果
  &NBSP;&NBSP;&NBSP;&NBSP;的八进制常数整数后缀<子>选择 的结果
  &NBSP;&NBSP;&NBSP;&NBSP;的十六进制常数整数后缀<子>选择

integer-constant:
    decimal-constant integer-suffixopt
    octal-constant integer-suffixopt
    hexadecimal-constant integer-suffixopt

十进制常数的:结果
  &NBSP;&NBSP;&NBSP;&NBSP;的非零数字的结果
  &NBSP;&NBSP;&NBSP;&NBSP;的十进制常数数字

八进制常数的:结果
  &NBSP;&NBSP;&NBSP;&NBSP; 0 结果
  &NBSP;&NBSP;&NBSP;&NBSP;的八进制常数八进制数字

十六进制常数的:结果
  &NBSP;&NBSP;&NBSP;&NBSP; ...结果
  &NBSP;&NBSP;&NBSP;&NBSP; ...

hexadecimal-constant:
    ...
    ...

这篇关于0是一个八进制或在C小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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