int变量的大小 [英] size of int variable

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

问题描述

如何为int的大小决定?

How the size of int is decided?

这是真的,INT的大小将取决于处理器。对于32位机,这将是32位,并且16位是16

Is it true that the size of int will depend on the processor. For 32-bit machine, it will be 32 bits and for 16-bit it's 16.

在我的机器上它显示为32位,虽然该机拥有64位处理器和64位Ubuntu安装。

On my machine it's showing as 32 bits, although the machine has 64-bit processor and 64-bit Ubuntu installed.

推荐答案

这取决于执行。 C标准保证的唯一的事情就是

It depends on the implementation. The only thing the C standard guarantees is that

sizeof(char) == 1

sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)

和也为类型,这意味着一些重新presentable最小值即字符长度至少为8位, INT 至少为16位,等等。

and also some representable minimum values for the types, which imply that char is at least 8 bits long, int is at least 16 bit, etc.

因此​​,它必须由实现(编译器,OS,......),并进行记录。

So it must be decided by the implementation (compiler, OS, ...) and be documented.

这篇关于int变量的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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