-5

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

我正在搜索如何将无符号整数表示为 c 中的数据类型,但我对如何呈现 uint64 感到困惑?是否可以在 c 中使用 uint64 作为 udouble ?请有人指导我?会支持吗??

以上所有内容的格式说明符是什么?

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

4

2 回答 2

3

所有这些类型 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;
于 2014-03-06T14:06:03.683 回答
2
#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
于 2014-03-06T14:06:21.217 回答