c中未签名整数的类型是什么

what is the type of unsigned integers in c?

本文关键字:类型 是什么 整数      更新时间:2023-10-16

uint8可以表示为ubyte,uint16可以表示为u word,uint32可以表示为ulong,uint64可以表示为?

我正在搜索如何将未签名的整数表示为C中的数据类型,但我对如何呈现UINT64感到困惑?是否可以将UINT64用作C中的UINT64?请有人引导我?它会支持吗?

上述所有格式的指定符是什么?

我只是在添加这一行,因为它要求身体不符合要求并告诉添加一些内容。所以我添加了。

所有这些类型uint8,uint16,uint32,uint64不是标准的基本类型,它们是typedef名称或实现定义的类型

至于uint64,可以将其定义为

typedef unsigned long long uint64;

考虑到已定义了积分类型的大小。因此,在上面的定义中可能足以使用unsigned long,因为在某些平台上sizeof( unsigned long)可以等于8个字节。

如果要使用不依赖二手平台的标准积分类型,则应包括标题<cstdint>

与其他定义类型中有以下未签名类型定义

typedef unsigned integer type uint8_t; // optional
typedef unsigned integer type uint16_t; // optional
typedef unsigned integer type uint32_t; // optional
typedef unsigned integer type uint64_t; // optional
typedef unsigned integer type uint_fast8_t;
typedef unsigned integer type uint_fast16_t;
typedef unsigned integer type uint_fast32_t;
typedef unsigned integer type uint_fast64_t;
typedef unsigned integer type uint_least8_t;
typedef unsigned integer type uint_least16_t;
typedef unsigned integer type uint_least32_t;
typedef unsigned integer type uint_least64_t;
#include <stdint.h>

获取在全局名称空间中定义的所有类型。

#include <cstdint>

在命名空间std中定义它。

在我的实施中,即在stdint.h中我可以找到:

#if __WORDSIZE == 64
typedef unsigned long int   uint64_t;
#else
__extension__
typedef unsigned long long int  uint64_t;
#endif

uint32_t

#ifndef __uint32_t_defined
typedef unsigned int        uint32_t;
# define __uint32_t_defined
#endif