长和长有什么区别 [英] What's the difference between long long and long

查看:314
本文介绍了长和长有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;
}


推荐答案

在主要的32位平台:


  • int 为32位

  • long 也是32位

  • / li>
  • int is 32 bits
  • long is 32 bits as well
  • long long is 64 bits

在主要的64位平台上:

On major 64-bit platforms:


  • int 是32位

  • / li>
  • long long 也是64位元

  • int is 32 bits
  • long is either 32 or 64 bits
  • long long is 64 bits as well

按标准进行:


  • int 必须至少为16位

  • 必须至少为32位

  • 必须至少为64位

  • int must be at least 16 bits
  • long must be at least 32 bits
  • long long must be at least 64 bits

如果我错了,请更正。

如果你需要一个特定的整数大小的特定应用程序,而不是相信编译器选择你想要的大小, #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 c $ c> uint32_t

  • int64_t uint64_t

  • int8_t and uint8_t
  • int16_t and uint16_t
  • int32_t and uint32_t
  • int64_t and uint64_t

您可能也会对 #include< stddef.h> (或< cstddef> ):


  • size_t


  • ptrdiff_t

  • size_t
  • ptrdiff_t

这篇关于长和长有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆