什么0LL或0x0UL是什么意思? [英] What do 0LL or 0x0UL mean?

查看:18507
本文介绍了什么0LL或0x0UL是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了谷歌围棋教程并看到这个在常量部分:

I am reading the Google Go tutorial and saw this in the constants section:

有像0LL或0x0UL没有常量

There are no constants like 0LL or 0x0UL

我试着做了谷歌搜索,但所有出现在哪里的人正在使用这些常量,但没有解释他们的意思实例。 0X应该启动一个十六进制文字,但这些都不是在一个十六进制数是可能的字符。

I tried to do a Google search but all that comes up are instances where people are using these constants but no explanation as to what they mean. 0x is supposed to start a hexadecimal literal but these are not characters that are possible in a hexadecimal number.

推荐答案

这些都是在C和C ++的常量。后缀 LL 表示常量的类型为长长 UL 办法无符号长

These are constants in C and C++. The suffix LL means the constant is of type long long, and UL means unsigned long.

在一般情况下,每个重新presents一个,每个 U U 重新presents一个符号。因此,例如

In general, each L or l represents a long and each U or u represents an unsigned. So, e.g.

1uLL

表示常数1型无符号长长

此也适用于浮点数

1.0f    // of type 'float'
1.0     // of type 'double'
1.0L    // of type 'long double'

和字符串和字符,但它们是prefixes:

and strings and characters, but they are prefixes:

 'A'   // of type 'char'
L'A'   // of type 'wchar_t'
u'A'   // of type 'char16_t' (C++0x only)
U'A'   // of type 'char32_t' (C++0x only)


在C和C ++中的整型常量使用它们的原始类型,它可能会由于整数溢出漏洞评估:


In C and C++ the integer constants are evaluated using their original type, which can cause bugs due to integer overflow:

long long nanosec_wrong = 1000000000 * 600;
// ^ you'll get '-1295421440' since the constants are of type 'int'
//   which is usually only 32-bit long, not big enough to hold the result.

long long nanosec_correct = 1000000000LL * 600
// ^ you'll correctly get '600000000000' with this

int secs = 600;
long long nanosec_2 = 1000000000LL * secs;
// ^ use the '1000000000LL' to ensure the multiplication is done as 'long long's.

在谷歌转到所有整数评为大整数(没有截断发生),

In Google Go, all integers are evaluated as big integers (no truncation happens),

    var nanosec_correct int64 = 1000000000 * 600

和没有正常的算术推广

    var b int32 = 600
    var a int64 = 1000000000 * b
    // ^ cannot use 1000000000 * b (type int32) as type int64 in assignment

所以后缀不是必要的。

so the suffixes are not necessary.

这篇关于什么0LL或0x0UL是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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