floating point literal
From cppreference.com
Floating point literal defines a compile-time constant whose value is specified in the source file.
[edit] Syntax
A floating-point literals have two syntaxes. The first one consists of the following parts:
-
- nonempty sequence of decimal digits containing a decimal point character (defines significand)
- (optional)
e
orE
followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent) - (optional) a suffix type specifier as a
l
,f
,L
orF
The second one consists of the following parts:
-
- nonempty sequence of decimal digits (defines significant)
-
e
orE
followed with optional minus or plus sign and nonempty sequence of decimal digits (defines exponent) - (optional) a suffix type specifier as a
l
,f
,L
orF
The suffix type specifier defines the actual type of the floating-point literal:
-
- (no suffix) defines double
-
f F
defines float -
l L
defines long double
[edit] Explanation
A decimal scientific notation is used, meaning that the exponent is the power of 10 by which the significant is multiplied.
The mathematical meaning of 123e4 is 123×104
[edit] Example
std::cout << 123.456e-67 << '\n' << .1E4f << '\n' << 58. << '\n' << 4e2 << '\n';
Output:
1.23456e-65 1000 58 400