int值前面的额外0是什么意思? [英] What does an extra 0 in front of an int value mean?
本文介绍了int值前面的额外0是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从一段混乱的代码中获得启发,我有一个关于将值分配给整数的小问题:
Inspiring from a obfuscated piece of code, I have a small question regarding to assign value to an integer:
#include <iostream>
#include <cstdio>
int main() {
int i = 0101;
std::cout << i << "\n";
}
输出为65,我不知道65来自哪里?知道吗?
And the output was 65, and I have no idea where 65 came from? Any idea?
推荐答案
它指定一个八进制(基数为8)的数字: 0101 == 1 * (8 * 8)+ 1 == 65
。
It specifies an octal (base-8) number: 0101 == 1 * (8 * 8) + 1 == 65
.
这篇关于int值前面的额外0是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文