关于一道C++的 常整型数问题!

来源:百度知道 编辑:UC知道 时间:2024/06/28 06:21:21
在C++中,合法的常整型数是()
A. 0L B.4962710 C.0.054838743 D.2.1869e10
对不起, 题目写错了。 是合法的 长整型常数 是()

我看答案有点出入啊! 标准答案给的是 D

答案是错的。正确答案是A,B也勉勉强强算可以。D是绝对不行的,D是浮点型(float)。详情可以参考C++官方网站如下几行(英文):
The exponent, if present, specifies the magnitude of the number as a power of 10, as shown in the following example:

18.46e0 // 18.46
18.46e1 // 184.6

The exponent may be specified using e or E, which have the same meaning, followed by an optional sign (+ or -) and a sequence of digits. If an exponent is present, the trailing decimal point is unnecessary in whole numbers such as 18E0.

我这里有一份我翻译的中文的版本,但是暂时不知道到哪里去了……
而A则是字面值长整型常量,具体英文解释如下:

To specify an unsigned type, use either the u or U suffix. To specify a long type, use either the l or L suffix. For example:

unsigned uVal = 328u; // Unsigned value
long lVal = 0x7FFFFFL; // Long value specified
// as hex constant
unsigned long ulVal = 0776745ul; // Unsigned long value

选A
C和D 不加以解释。
B是字面常量,对于一个整