請教 2.1*3 這里的2.1是float型還是double型?謝謝
uj5u.com熱心網友回復:
2.1為double2.1f為float
uj5u.com熱心網友回復:
2.1 ×3默認是按照double(高一級的精度)來處理的。除非指定,比如2.1f * 3這是按照float型別來計算的。uj5u.com熱心網友回復:
常量當然也有型別:C Floating-Point Constants
A “floating-point constant” is a decimal number that represents a signed real number. The representation of a signed real number includes an integer portion, a fractional portion, and an exponent. Use floating-point constants to represent floating-point values that cannot be changed.
Syntax
floating-point-constant :
fractional-constant exponent-part opt floating-suffix opt
digit-sequence exponent-part floating-suffix opt
fractional-constant :
digit-sequence opt . digit-sequence
digit-sequence .
exponent-part :
e sign opt digit-sequence
E sign opt digit-sequence
sign : one of
+ –
digit-sequence :
digit
digit-sequence digit
floating-suffix : one of
f l F L
You can omit either the digits before the decimal point (the integer portion of the value) or the digits after the decimal point (the fractional portion), but not both. You can leave out the decimal point only if you include an exponent. No white-space characters can separate the digits or characters of the constant.
The following examples illustrate some forms of floating-point constants and expressions:
15.75
1.575E1 /* = 15.75 */
1575e-2 /* = 15.75 */
-2.5e-3 /* = -0.0025 */
25E-4 /* = 0.0025 */
Floating-point constants are positive unless they are preceded by a minus sign (–). In this case, the minus sign is treated as a unary arithmetic negation operator. Floating-point constants have type float, double, long, or long double.
A floating-point constant without an f, F, l, or L suffix has type double. If the letter f or F is the suffix, the constant has type float. If suffixed by the letter l or L, it has type long double. For example:
100L /* Has type long double */
100F /* Has type float */
100D /* Has type double */
Note that the Microsoft C compiler maps long double to type double. See Storage of Basic Types in Chapter 3 for information about type double, float, and long.
You can omit the integer portion of the floating-point constant, as shown in the following examples. The number .75 can be expressed in many ways, including the following:
.0075e2
0.075e1
.075e1
75e-2
uj5u.com熱心網友回復:
C Integer ConstantsAn “integer constant” is a decimal (base 10), octal (base 8), or hexadecimal (base 16) number that represents an integral value. Use integer constants to represent integer values that cannot be changed.
Syntax
integer-constant :
decimal-constant integer-suffix opt
octal-constant integer-suffix opt
hexadecimal-constant integer-suffix opt
decimal-constant :
nonzero-digit
decimal-constant digit
octal-constant :
0
octal-constant octal-digit
hexadecimal-constant :
0x hexadecimal-digit
0X hexadecimal-digit
hexadecimal-constant hexadecimal-digit
nonzero-digit : one of
1 2 3 4 5 6 7 8 9
octal-digit : one of
0 1 2 3 4 5 6 7
hexadecimal-digit : one of
0 1 2 3 4 5 6 7 8 9
a b c d e f
A B C D E F
integer-suffix :
unsigned-suffix long-suffix opt
long-suffix unsigned-suffix opt
unsigned-suffix : one of
u U
long-suffix : one of
l L
64-bit integer-suffix :
i64
Integer constants are positive unless they are preceded by a minus sign (–). The minus sign is interpreted as the unary arithmetic negation operator. (See Unary Arithmetic Operators in Chapter 4 for information about this operator.)
If an integer constant begins with the letters 0x or 0X, it is hexadecimal. If it begins with the digit 0, it is octal. Otherwise, it is assumed to be decimal.
The following lines are equivalent:
0x1C /* = Hexadecimal representation for decimal 28 */
034 /* = Octal representation for decimal 28 */
No white-space characters can separate the digits of an integer constant. These examples show valid decimal, octal, and hexadecimal constants.
/* Decimal Constants */
10
132
32179
/* Octal Constants */
012
0204
076663
/* Hexadecimal Constants */
0xa or 0xA
0x84
0x7dB3 or 0X7DB3
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
我不敢保證國內的大學教授是否見過或者看過C標準。路子不是一般的“野”。uj5u.com熱心網友回復:
謝謝,現在好像有C18了,哪里可以C標準的完整檔案呢?
謝謝
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/247363.html
標籤:C語言
上一篇:求一個字串處理的程式
