long long 和 long 和有什么不一样
long long 和 long 有什么区别?而且它们都不适用于 12 位数字 (600851475143),我是不是忘记了什么?
What's the difference between long long and long? And they both don't work with 12 digit numbers (600851475143), am I forgetting something?
#include <iostream>
using namespace std;
int main(){
long long a = 600851475143;
}
推荐答案
按照标准,保证的是:
int必须至少为 16 位long必须至少为 32 位long long必须至少为 64 位
intmust be at least 16 bitslongmust be at least 32 bitslong longmust be at least 64 bits
在主要的 32 位平台上:
On major 32-bit platforms:
int是 32 位long也是 32 位long long是 64 位
intis 32 bitslongis 32 bits as welllong longis 64 bits
在主要的 64 位平台上:
On major 64-bit platforms:
int是 32 位long是 32 位或 64 位long long也是 64 位
intis 32 bitslongis either 32 or 64 bitslong longis 64 bits as well
如果您需要特定应用程序的特定整数大小,而不是相信编译器会选择您想要的大小,#include <stdint.h>(或 <cstdint>) 所以你可以使用这些类型:
If you need a specific integer size for a particular application, rather than trusting the compiler to pick the size you want, #include <stdint.h> (or <cstdint>) so you can use these types:
int8_t和uint8_tint16_t和uint16_tint32_t和uint32_tint64_t和uint64_t
int8_tanduint8_tint16_tanduint16_tint32_tanduint32_tint64_tanduint64_t
您可能还对#include <stddef.h>(或<cstddef>)感兴趣:
You may also be interested in #include <stddef.h> (or <cstddef>):
size_tptrdiff_t
相关文章