是C ++ 11的长长真的至少64位? [英] Is C++11's long long really at least 64 bits?

查看:112
本文介绍了是C ++ 11的长长真的至少64位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它说这里在这里,类型 long long 的长度至少与 int 不小于64位。我一直在看看C ++ 11标准§3.9.1基本类型部分,我找不到任何参考64位。我可以找到的是它至少与 long int 一样长,这至少等于 int 。该标准将 long long 列为标准整数类型,而不是扩展这个断言 long long 至少保存64位是真的。如果是,它在哪里说明?
请注意,我只是谈论C ++ 11标准 long long

解决方案

C ++标准引用了C标准,参见[c.limits]。在< climits> 中定义与C的< limits相同含义的 LLONG_MAX h> LLONG_MAX 。这是C必须说的:


5.2.4.2.1整数类型的大小< ; limits.h>



下面给出的值应由适用于 #if 预处理指令。 [...]它们的实现定义的值应该等于或大于所示的大小(绝对值),具有相同的符号。



- 类型 long long int

的对象的最大值

LLONG_MAX +9223372036854775807 // 2 63 -1


必须能够表示值 9223372036854775807 的签名类型需要64位或更多位。


It says here and here that type long long is at least as long as an int and has no fewer than 64 bits. I have been looking at the C++11 standard §3.9.1 Fundamental Types section and I cannot find any reference to 64 bits. All I can find is that it is at least as long at long int, which is at least as long as int. The standard lists long long as a standard integer type, as opposed to an extended one, so I am wondering whether this assertion that long long holds at least 64 bits is true. And if it is, where is it stated? Please note that I am talking about C++11 standard long long only.

解决方案

The C++ standard references the C standard for this, see [c.limits]. LLONG_MAX is defined in <climits> with the same meaning as C's <limits.h>'s LLONG_MAX. And this is what C has to say:

5.2.4.2.1 Sizes of integer types <limits.h>

The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.

[...]

-- maximum value for an object of type long long int

LLONG_MAX +9223372036854775807 // 263 -1

A signed type that must be capable of representing the value 9223372036854775807 requires 64 bits or more.

这篇关于是C ++ 11的长长真的至少64位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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