问题描述
这似乎所有的人都需要4个字节的空间,
It seems all of them take 4 bytes of space,
有啥区别?
推荐答案
首先,int的长度/长是不确定的。所以,你的编译器,一个 INT
和长
可能是相同的,但是这不是跨编译器普及。
First of all, the size of int/long is unspecified. So on your compiler, an int
and a long
might be the same, but this isn't universal across compilers.
至于之间的差异无符号长
和长
:
假设4个字节,一个长
的 -2,147,483,648
到 2,147,483,647 。一个unsigned long具有
0
向范围 4,294,967,295
。
Assuming 4 bytes, a long
has the range of -2,147,483,648
to 2,147,483,647
. An unsigned long has the range of 0
to 4,294,967,295
.
另外一个区别是溢出。对于一个符号类型,溢出具有不确定的行为。但对于无符号类型,溢出是保证环绕。
One other difference is with overflow. For a signed type, an overflow has unspecified behavior. But for an unsigned type, overflow is guaranteed to "wrap around."
这篇关于是什么在C / C ++的无符号长/长/ INT之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!