010是8而不是10 :( [英] 010 is 8 and not 10 :(
问题描述
我发现以零开头的数字在基数8中评估。
示例 -
int numbers [] = {001,
010,//这被视为8而
不是10 :(奇怪:( :(
};
我发现编译器没有抱怨并继续执行
将八进制转换为相应的十进制值:( :( 。
最初我很震惊,但后来练习了它。
这个选项''0''在一个数字之前将其视为C中的八进制导致
问题有时候(容易出错的路径)。
八,我们只有'C'中的数字前面有一个0。
应该有其他约定吗?你怎么看?
Thx,
Karthik Balaguru
Hi,
I find that numbers beginning with a zero are evaluated in base 8.
Example -
int numbers[] = { 001,
010, // This is treated as 8 and
not as 10 :( Strange :(:(
};
I find that compiler does not complain and continues performing after
converting the octal to the corresponding decimal value :(:(.
Initially i was shocked , But later practised to it.
This option of ''0'' before a number to treat it as octal in C causes
problem sometimes(Easy path for error) .
Octal, we just have a 0 infront of the number in ''C'' .
There should be someother convention ? What do you think ?
Thx,
Karthik Balaguru
推荐答案
karthikbalaguru写道:
karthikbalaguru wrote:
我发现nu以零开头的mbers在基数8中进行评估。
示例 -
int numbers [] = {001,
010 ,//这被视为8和
不是10 :(奇怪:( :(
};
我发现编译器没有抱怨并继续执行
将八进制转换为相应的十进制值:( :(。
最初我很震惊,但后来实践了它。
这个选项''''在一个数字之前将其视为C中的八进制导致
有时会出现问题(错误路径容易出错)。 />
八进制,我们在''C'中的数字前面只有0。
还应该有其他约定吗?你觉得怎么样?
Hi,
I find that numbers beginning with a zero are evaluated in base 8.
Example -
int numbers[] = { 001,
010, // This is treated as 8 and
not as 10 :( Strange :(:(
};
I find that compiler does not complain and continues performing after
converting the octal to the corresponding decimal value :(:(.
Initially i was shocked , But later practised to it.
This option of ''0'' before a number to treat it as octal in C causes
problem sometimes(Easy path for error) .
Octal, we just have a 0 infront of the number in ''C'' .
There should be someother convention ? What do you think ?
比如?
这个约定可以追溯到很久以前,永远不会改变。
-
Ian Collins。
Such as?
The convention goes back a long way and is never likely to change.
--
Ian Collins.
karthikbalaguru< ka ****** *********@gmail.com写道:
karthikbalaguru <ka***************@gmail.comwrote:
我发现以零开头的数字在基数8中评估。
I find that numbers beginning with a zero are evaluated in base 8.
没有狗屎,Sherlock。这就是C的方式,而且一直如此。交易。
Richard
No shit, Sherlock. This is how C is, and always has been. Deal.
Richard
9月13日下午12:40,karthikbalaguru< karthikbalagur ... @ gmail.com> ;
写道:
On Sep 13, 12:40 pm, karthikbalaguru <karthikbalagur...@gmail.com>
wrote:
我发现以零开头的数字是在基数8中评估。
示例 -
int numbers [] = {001,
010,//这是对待的as 8和
不是10 :(奇怪:( :(
};
我发现编译器没有抱怨并继续执行
将八进制转换为相应的十进制值:( :(。
最初我很震惊,但后来练习了它。
这个选项''0''在一个数字之前将其视为C中的八进制导致
有时出现问题(错误路径容错)。
八月,我们在''C'中的数字前面只有0。
应该有另外一些c你觉得怎么样?
Thx,
Karthik Balaguru
Hi,
I find that numbers beginning with a zero are evaluated in base 8.
Example -
int numbers[] = { 001,
010, // This is treated as 8 and
not as 10 :( Strange :(:(
};
I find that compiler does not complain and continues performing after
converting the octal to the corresponding decimal value :(:(.
Initially i was shocked , But later practised to it.
This option of ''0'' before a number to treat it as octal in C causes
problem sometimes(Easy path for error) .
Octal, we just have a 0 infront of the number in ''C'' .
There should be someother convention ? What do you think ?
Thx,
Karthik Balaguru
它应该是:(早期代码快照中没有逗号)
示例 -
int numbers [] = {001,
010 //这被视为8而不是10:
(奇怪:( :(
};
Thx,
Karthik Balaguru
It should be : (No comma in the earlier snapshot of code)
Example -
int numbers[] = { 001,
010 // This is treated as 8 and not as 10 :
( Strange :(:(
};
Thx,
Karthik Balaguru
这篇关于010是8而不是10 :(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!