C 中的类型有任何保证的最小尺寸吗? [英] Any guaranteed minimum sizes for types in C?

查看:15
本文介绍了C 中的类型有任何保证的最小尺寸吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您通常可以对数据类型的最小大小做出任何假设吗?

Can you generally make any assumptions about the minimum size of a data type?

我目前阅读的内容:

  • 字符:1 个字节
  • 短:2 字节
  • int:2 Byte,通常为 4 Byte
  • 长:4 字节

浮动???双重???

float.hlimits.h 中的值是否依赖于系统?

Are the values in float.h and limits.h system dependent?

推荐答案

维基百科文章:

short int 不得大于 int.
int 不能大于 long int.

A short int must not be larger than an int.
An int must not be larger than a long int.

short int 必须至少有 16 位长.
int 的长度必须至少为 16 位.
long int 必须至少为 32 位长.
long long int 必须至少为 64 位长.

A short int must be at least 16 bits long.
An int must be at least 16 bits long.
A long int must be at least 32 bits long.
A long long int must be at least 64 bits long.

标准并不要求这些尺寸中的任何一个都必须不同.这是完全有效的,例如,如果所有四种类型都是 64 位长.

The standard does not require that any of these sizes be necessarily different. It is perfectly valid, for example, if all four types are 64 bits long.

这篇关于C 中的类型有任何保证的最小尺寸吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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