C++ LL是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15575054/
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
What does LL mean?
提问by Luchian Grigore
采纳答案by Andy Prowl
It is specified in Paragraph 2.14.2 of the C++11 Standard:
它在 C++11 标准的第 2.14.2 段中指定:
2.14.2 Integer literals
2.14.2 整数文字
[...]
long-long-suffix: one of
ll LL
[...]
长长后缀:之一
ll LL
Paragraph 2.14.2/2, and in particular Table 6, goes on specifying the meaning of the suffix for decimal, octal, and hexadecimal constants, and the types they are given.
第 2.14.2/2 段,特别是表 6,继续指定十进制、八进制和十六进制常量的后缀的含义,以及它们的类型。
Since 0is an octal literal, the type of 0LLis long long int:
由于0是八进制文字,因此类型0LL为long long int:
#include <type_traits>
int main()
{
// Won't fire
static_assert(std::is_same<decltype(0LL), long long int>::value, "Ouch!");
}
回答by cdhowie
LLis the suffix for long-long, which is 64-bit on most (all?) C/C++ implementations. So 0LLis a 64-bit literal with the value of 0.
LL是 long-long 的后缀,它在大多数(所有?)C/C++ 实现中都是 64 位的。这样0LL是为0的值的64位的文字。
This is similar to Lbeing the suffix for a long literal, which on most 32- and 64-bit C/C++ implementations is the same size as a non-long int. (On 16-bit implementations, the size of intis usually 16 bits, and so the Lsuffix would indicate a 32-bit integer literal in contrast to the default of 16 bits.)
这类似于L作为 long 文字的后缀,在大多数 32 位和 64 位 C/C++ 实现中,其大小与非 long 相同int。(在 16 位实现中, 的大小int通常为 16 位,因此L与默认的 16 位相比,后缀将指示 32 位整数文字。)
回答by Joseph Mansfield
0LLis an integer literal. It's suffix is LLwhich determines the possible set of types that it might have. For a decimal constant, the type will be long long int. For an octal or hexadecimal constant, the type will be long long intor unsigned long long intif necessary. In the case of 0LL, the literal is of type long long int.
0LL是一个整数文字。它的后缀LL决定了它可能具有的类型集。对于十进制常量,类型将为long long int. 对于八进制或十六进制常量,类型将为long long int或unsigned long long int如有必要。在 的情况下0LL,文字的类型为long long int。
The type of an integer literal is the first of the corresponding list in Table 6 in which its value can be represented.
Table 6 - Types of integer constants
Suffix Decimal constants Octal or hexadecimal constant ... ll or LL long long int long long int unsigned long long int ...
整数文字的类型是表 6 中相应列表中的第一个,可以在其中表示其值。
表 6 - 整数常量的类型
Suffix Decimal constants Octal or hexadecimal constant ... ll or LL long long int long long int unsigned long long int ...

