在C ++中int和long之间有什么区别? [英] What is the difference between an int and a long in C++?
问题描述
如果我错了,请更正我。
Correct me if I am wrong,
int是4个字节,值范围从-2,147,483,648到2,147,483,647(2 ^ 31)
long是4个字节,值范围从-2,147,483,648到2,147,483,647(2 ^ 31)
int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)
C ++有什么区别?它们是否可以互换使用?
What is the difference in C++? Can they be used interchangeably?
推荐答案
例如,在Windows下,它们是相同的,但是例如在Alpha系统上,long是64位,而int是32位。本文章涵盖了在可变平台上的Intel C ++编译器的规则。总结:
For example, under Windows they are the same, but for example on Alpha systems a long was 64 bits whereas an int was 32 bits. This article covers the rules for the Intel C++ compiler on variable platforms. To summarize:
OS arch size
Windows IA-32 4 bytes
Windows Intel 64 4 bytes
Windows IA-64 4 bytes
Linux IA-32 4 bytes
Linux Intel 64 8 bytes
Linux IA-64 8 bytes
Mac OS X IA-32 4 bytes
Mac OS X Intel 64 8 bytes
这篇关于在C ++中int和long之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!