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 位
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
这篇关于long long 和 long 和有什么不一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:long long 和 long 和有什么不一样
基础教程推荐
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- c++ STL设置差异 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
