C++ U后缀的含义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4380691/
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
Meaning of U suffix
提问by lovespring
What does the postfix (or suffix) U
mean for the following values?
后缀(或后缀)U
对以下值意味着什么?
0U
100U
回答by ruslik
It stands for unsigned
.
它代表unsigned
.
When you declare a constant, you can also specify its type. Another common example is L
, which stands for long
. (and you have to put it twice to specify a 64-bit constant).
声明常量时,还可以指定其类型。另一个常见的例子是L
,它代表long
。(你必须把它放两次才能指定一个 64 位常量)。
Example: 1ULL
.
例子:1ULL
。
It helps in avoiding explicit casts.
它有助于避免显式转换。
回答by wallyk
Integer constants in C and C++ can optionally have several suffixes:
C 和 C++ 中的整数常量可以选择有几个后缀:
123u the value 123 is an unsigned int
123l (that's a lowercase L) 123 is a signed long
123L ditto
123uL unsigned long
123LL a signed long long, a 64 bit or 128 bit value (depending on the environment)
123uLL unsigned long long
123u 值 123 是无符号整数
123l(即小写 L) 123 是有符号长
整型 123L 同上
123uL 无符号长
整型 123LL 有符号长整型、64 位或 128 位值(取决于环境)
123uLL 无符号长整型