What#39;s the difference between long long and long(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 位
int
must be at least 16 bitslong
must be at least 32 bitslong long
must be at least 64 bits
在主要的 32 位平台上:
On major 32-bit platforms:
int
是 32 位long
也是 32 位long long
是 64 位
int
is 32 bitslong
is 32 bits as welllong long
is 64 bits
在主要的 64 位平台上:
On major 64-bit platforms:
int
是 32 位long
是 32 位或 64 位long long
也是 64 位
int
is 32 bitslong
is either 32 or 64 bitslong long
is 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_t
int16_t
和uint16_t
int32_t
和uint32_t
int64_t
和uint64_t
int8_t
anduint8_t
int16_t
anduint16_t
int32_t
anduint32_t
int64_t
anduint64_t
您可能还对#include <stddef.h>
(或<cstddef>
)感兴趣:
You may also be interested in #include <stddef.h>
(or <cstddef>
):
size_t
ptrdiff_t
这篇关于long long 和 long 和有什么不一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:long long 和 long 和有什么不一样


- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 从python回调到c++的选项 2022-11-16
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- C++ 协变模板 2021-01-01