CodePudding user response:
2.1 double2.1 f is a float
CodePudding user response:
2.1 x 3 default is according to the double (higher precision) to deal with, unless specified, such as 2.1 f * 3 this is calculated according to the float type,CodePudding user response:
Constants, of course, also have a type:C Floating - Point Constants
A floating - point "constant" is A decimal number that represents The signed A real number. The representation of A signed real number includes an integer portion, A fractional portion, and an exponent. The Use of floating - point constants to represent floating - point values that always 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 a l f l
You can omit either the who before the decimal point (the integer portion of the value) or the who 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 who or the characters of the constant.
The following examples illustrateenrollment some forms of floating - point constants and expressions:
15.75
E1/* 1.575=15.75 */
E - 1575/* 2=15.75 */
2.5 e-3/*=0.0025 */
25/* e - 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 from the type double. If the letter f/f is the suffix, the constant from the type float. If suffixed by the letter l or l, it has the type long double. For example:
100 l/* from the type long double */
100 f/* Has type float */
100 d/* from the 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 the type double, float, and long.
You can omit the integer portion of the floating - point constant, to in the following examples. The number. The 75 can be expressed in many ways, o the following:
. 0075 e2
0.075 e1
. 075 e1
E - 75
2
CodePudding user response:
C Integer ConstantsAn "integer constant" is a decimal (base 10), octal (base 8), or hexadecimal (base 16) number that represents An integral value. Use the integer constants to represent An integer values that always be changed.
Syntax
The integer - constant:
A decimal - constant integer - suffix opt
Octal - constant integer - suffix opt
Hexadecimal - constant integer - suffix opt
A decimal - constant:
Nonzero - digit
A decimal - constant digit
Octal - constant:
0
Octal - constant octal digit -
Hexadecimal - constant:
0 x hexadecimal digit -
0 x 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
The 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 0 x or 0 x, 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:
/*=0 x1c Hexadecimal representation for a decimal 28 */
034/*=Octal representation for a decimal 28 */
No white - space characters can separate the who 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 */
0 xa or 0 xa
0 x84
0 x7db3 or 0 x7db3
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull