C 类型之间的区别 int32_t int_least32_t 等 [英] Difference between C-Types int32_t int_least32_t etc

查看:45
本文介绍了C 类型之间的区别 int32_t int_least32_t 等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾读过 int32_t 的长度正好是 32 位,而 int_least32_t 的长度至少为 32 位,但它们在我的 stdint.h 中有相同的 typedef:

I have ever read that int32_t is exact 32 bits long and int_least32_t only at least 32 bits, but they have both the same typedefs in my stdint.h:

typedef int  int_least32_t;

typedef int  int32_t;

那么区别在哪里呢?他们完全一样...

So where is the difference? They exactly the same...

推荐答案

int32_t 是有符号整数类型,宽度为 32 位,没有填充位,负值使用 2 的补码.int_least32_t 是最小有符号整数类型,宽度至少为 32 位.仅当实现直接支持该类型时才提供这些.

int32_t is signed integer type with width of exactly 32 bits with no padding bits and using 2's complement for negative values. int_least32_t is smallest signed integer type with width of at least 32 bits. These are provided only if the implementation directly supports the type.

您看到的 typedef 只是意味着在您的环境中,标准 int 类型本身满足了这两个要求.这并不意味着这些 typedef 在不同的环境中是相同的.

The typedefs that you are seeing simply means that in your environment both these requirements are satisfied by the standard int type itself. This need not mean that these typedefs are the same on a different environment.

这篇关于C 类型之间的区别 int32_t int_least32_t 等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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