在C整数的大小取决于什么? [英] integer size in c depends on what?

查看:165
本文介绍了在C整数的大小取决于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

整数的大小取决于什么?是否是编译器相关的或依赖MACHIN?

Size of the integer depends on what?whether it is compiler dependent or machin dependent?

推荐答案

这是实现相关。 C标准只要求:

It's implementation-dependent. The C standard only requires that:


  • 字符已至少有8位

  • 至少有16位

  • INT 至少有16位

  • 至少有32位

  • 长长已至少有64位(1999年加入)

  • 的sizeof(char)的和乐;的sizeof(短)文件;的sizeof(INT)及乐;的sizeof(长)乐;的sizeof(久长)

  • char has at least 8 bits
  • short has at least 16 bits
  • int has at least 16 bits
  • long has at least 32 bits
  • long long has at least 64 bits (added in 1999)
  • sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long) ≤ sizeof(long long)

在16位/ 32位的天,的实际的标准是:

In the 16/32-bit days, the de facto standard was:


  • INT 是原生整数大小

  • 其他类型被最小尺寸允许

  • int was the "native" integer size
  • the other types were the minimum size allowed

不过,64位系统通常做的的让 INT 64位,这将创造有三个的尴尬局面64位类型和没有32位的类型。的部分的编译器扩展为64位。

However, 64-bit systems generally did not make int 64 bits, which would have created the awkward situation of having three 64-bit types and no 32-bit type. Some compilers expanded long to 64 bits.

这篇关于在C整数的大小取决于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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