在C+中,int和long有什么区别?如果我错了就纠正我,int是4个字节,其值范围从-2,147,483,648到2,147,483,647(2^31)。Long是4个字节,其值范围从-2,147,483,648到2,147,483,647(2^31)。C+有什么区别?它们可以互换使用吗?
3 回答
慕无忌1623718
TA贡献1744条经验 获得超4个赞
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
慕标琳琳
TA贡献1830条经验 获得超9个赞
sizeof(char) == 1sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)// FROM @KTC. The C++ standard also has:sizeof(signed char) == 1sizeof(unsigned char) == 1// NOTE: These size are not specified explicitly in the standard.// They are implied by the minimum/maximum values that MUST be supported// for the type. These limits are defined in limits.hsizeof(short) * CHAR_BIT >= 16sizeof(int) * CHAR_BIT >= 16sizeof(long) * CHAR_BIT >= 32sizeof(long long) * CHAR_BIT >= 64CHAR_BIT >= 8 // Number of bits in a byte
- 3 回答
- 0 关注
- 1387 浏览
添加回答
举报
0/150
提交
取消