为什么没有int128_t? [英] Why isn't there int128_t?
问题描述
若干编译器提供128位的整数类型,但没有我所使用的那些的提供的typedef int128_t
。为什么呢?
据我记得,标准
- 储量
int128_t
为此 - 鼓励提供这种类型提供的typedef 实施
- 强制要求这样的实现提供了一个
还会将intmax_t
至少为128位
(而且,我不认为我已经用实际符合最后一点实现)
我指的是C标准;我认为C ++标准继承了 我知道,海湾合作委员会实现了128位有符号和无符号整数,名称 即使它提供了一个标准的128位型的实施,该标准没有的需要的 这些类型是可选的。然而,如果实现提供 ç允许实现来定义的扩展整型的名字是实现定义的关键字。 gcc的 特别是,如果 这是,在我看来,不幸的,但我不相信,这使GCC不合格。没有便携式程序可以依赖于 A number of compilers provide 128-bit integer types, but none of the ones I've used provide the typedefs As far as I recall, the standard (and, I do not believe I've used an implementation that actually conforms to that last point) I'll refer to the C standard; I think the C++ standard inherits the rules for I know that gcc implements 128-bit signed and unsigned integers, with the names Even for an implementation that provides a standard 128-bit type, the standard does not require These types are optional. However, if an implementation provides
integer types with widths of 8, 16, 32, or 64 bits, no padding bits,
and (for the signed types) that have a two’s complement
representation, it shall define the corresponding typedef names. C permits implementations to defined extended integer types whose names are implementation-defined keywords. gcc's In particular, if This is, in my opinion, unfortunate, but I don't believe it makes gcc non-conforming. No portable program can depend on the existence of 这篇关于为什么没有int128_t?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!&LT规则;从C <
; stdint.h&GT; / &LT; cstdint&GT / p>
__ int128
和无符号__int128
( __ int128
是实现定义的关键字)在一些平台上。 int128_t
或 uint128_t
来定义。引述 N1570 C标准的草稿第7.20.1.1:
整数类型为8的宽度,16,32,或64位,无填充比特,
和(用于签名的类型),该具有一个二的补
再presentation,应当定义相应的typedef名称。
块引用> __ int128
和无符号__int128
非常相似,扩展整型的标准定义的 - 但是GCC不对待他们的方式。相反,它会将其视为一个语言的扩展。 __ int128
和无符号__int128
是扩展整型的,那么GCC将需要定义还会将intmax_t
和 uintmax_t型
为这些类型(或某些类型的至少128位宽)。它没有这样做;相反,还会将intmax_t
和 uintmax_t型
只有64位。的存在__ int128
,或任何整数类型宽度大于64位。int128_t
. Why?
int128_t
for this purposeintmax_t
of at least 128 bits<stdint.h>
/ <cstdint>
from C.__int128
and unsigned __int128
(__int128
is an implementation-defined keyword) on some platforms.int128_t
or uint128_t
to be defined. Quoting section 7.20.1.1 of the N1570 draft of the C standard:
__int128
and unsigned __int128
are very similar to extended integer types as defined by the standard -- but gcc doesn't treat them that way. Instead, it treats them as a language extension.__int128
and unsigned __int128
were extended integer types, then gcc would be required to define intmax_t
and uintmax_t
as those types (or as some types at least 128 bits wide). It does not do so; instead, intmax_t
and uintmax_t
are only 64 bits.__int128
, or on any integer type wider than 64 bits.