Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
182 views
in Technique[技术] by (71.8m points)

c++ - Is C++11's long long really at least 64 bits?

It says on wikipedia and in Stroustrup's FAQ 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.

question from:https://stackoverflow.com/questions/10053113/is-c11s-long-long-really-at-least-64-bits

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...