【问题标题】:What should be the exact size of for unsigned long long [duplicate]unsigned long long 的确切大小应该是多少 [重复]
【发布时间】:2014-01-17 10:56:08
【问题描述】:

unsigned long long 的确切 typedef 应该是什么?
例如:

typedef unsigned int uint32 ; //考虑我的机器阅读
typedef unsigned char byte ;

那是什么

typedef unsigned long long ______ ;

uint64还是更多?

【问题讨论】:

  • 无。它的大小不固定为一个值。仅对其最小尺寸有要求。
  • 在大多数编译器上为 8 字节(64 位)。
  • typedef unsigned long long int uint64_t
  • 你为什么要 typedef int 到 'uint32'? uint 不是用于无符号整数吗?
  • 请修复typedef int uint32 ;,一些毫无戒心的新手最终会将其复制/粘贴到某处的代码中。让我想起了在野外看到的将TRUE 定义为0FALSE1 的代码,通过在枚举中粗心地声明它们。

标签: c++ c lint


【解决方案1】:

unsigned long long 保证大小至少为 64 位。因此,它等价于uint_least64_t

typedef unsigned long long uint_least_64_t

【讨论】:

  • 给定当前平台,它们通常是等效的。一个深奥的/未来的 C 兼容平台可能有 unsigned long long 作为 128 位无符号和 unsigned long 作为 64 位无符号。这样的系统不会保持与typedef unsigned long uint_least64_t; 的等效项。
【解决方案2】:
unsigned long long my_variable;

表示 my_variable 是 64 位(或更多)的无符号整数值

你可能会发现这也有帮助:

How many bytes is unsigned long long?

unsigned long long

的同义词
unsigned long long int

定义为

typedef unsigned long long int uint64_t

Standard Integer Types

【讨论】:

  • unsigned long long int 未定义为 uint64_tuint64_t可以定义为unsigned long long int,反向不是C指定的。
猜你喜欢
  • 2019-07-15
  • 1970-01-01
  • 2016-07-29
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多