C++ GCC 支持 long long int 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1523483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does GCC support long long int?
提问by Polaris878
Does GCC support:
GCC 是否支持:
long long int
which would be a 64-bit integer?
这将是一个 64 位整数?
Also, is long long int
part of the standard?
另外,是long long int
标准的一部分吗?
回答by Alex B
Yes GCC does support long long int
, which is a part of C99 standard.
是的 GCC 确实支持long long int
,这是 C99 标准的一部分。
The standard does not mandate its size in bits, but required values of LLONG_MIN
and LLONG_MAX
in <limits.h>
imply it's at least64-bit (exact64-bit wide integer types are int64_t
/uint64_t
from <stdint.h>
).
该标准不以位强制它的大小,但所需的值LLONG_MIN
并LLONG_MAX
在<limits.h>
暗示它是至少64位(精确64位宽的整数类型int64_t
/uint64_t
从<stdint.h>
)。
LLONG_MIN
must be at most-9223372036854775807
LLONG_MAX
must be at least9223372036854775807
LLONG_MIN
必须至多-9223372036854775807
LLONG_MAX
必须至少9223372036854775807
回答by Chris Lutz
long long int
is a part of the C99 standard, and I know GCC supports it. And now I can prove it.
long long int
是 C99 标准的一部分,我知道 GCC 支持它。现在我可以证明了。
回答by Mark Rushakoff
On my 32-bit machine,
在我的 32 位机器上,
int main()
{
printf("%d\n", sizeof(long long int));
return 0;
}
compiled with gcc
prints 8 (8 bytes * 8 bits/byte = 64 bits).
编译为gcc
打印 8(8 字节 * 8 位/字节 = 64 位)。
回答by DigitalRoss
Yes, long long
is part of C99, as well as long long
constants (10222333444555LL
) and a few support elements. (LLONG_MAX
, llrint(d)
, llround(d)
, some others.) And gcc has implemented it for some time now.
是的,long long
是 C99 的一部分,还有long long
常量 ( 10222333444555LL
) 和一些支持元素。( LLONG_MAX
, llrint(d)
, llround(d)
, 其他一些。) gcc 已经实现了一段时间了。
回答by eyalm
In order to print long long int variables:
为了打印 long long int 变量:
long long int lli = 100000000;
printf("%lld\n", lli);
回答by Lee B
long longs are well supported, and have been for a long long time [sorry]. As I understand it, this should have been 128 bit on 64-bit platforms, but for compatibility/portability reasons in GCC, has standardised on a 64-bit width.
多头得到了很好的支持,并且已经支持了很长时间[抱歉]。据我了解,这在 64 位平台上应该是 128 位,但出于 GCC 中的兼容性/可移植性原因,已标准化为 64 位宽度。
See also: (u)int128_t, and this discussion on GCC's 128-bit integer support
另请参阅:(u)int128_t,以及关于 GCC 的 128 位整数支持的讨论
回答by Marc W
I believe that usually an unsigned long long
is the traditional representation of a 64-bit integer. I'm assuming long long int
would work too, but I've never personally seen any 64-bit vars declared that way before.
我相信通常 anunsigned long long
是 64 位整数的传统表示形式。我假设它long long int
也能工作,但我个人以前从未见过任何以这种方式声明的 64 位变量。