Thank you for all these great inputs, and I think I get the ideas:
In essence, the suffix can only applied to constant.
The type float is 4-bytes, and therefore the range of value that a float can take is a lot smaller than a double, which is 8-bytes, and the range is therefore much larger (2^n).
Since a float typically has 7-digits of precision (and my compiler prints up to 6) and a double has 15...
1 2 3 4
|
cout << setprecision(16);
cout << 3.2323232323232323236456543534f << endl;
cout << 3.23232323232323232364565435345656756645654645645646456 << endl;
cout << 3.23232323232323232364565435345656756645654645645646456l << endl;
|
This will output
---- Hit any key to start.
3.232323169708252
3.232323232323232
3.232323232323232
---- Hit any key to continue.
|
I can see how the prefix plays the role to the literal constant.
However, if we declar something like
|
float a = 3.23232323232323232364565435345656756645654645645646456l
|
This will print out the exact output as the first one
---- Hit any key to start.
3.232323169708252
|
Instead of 3.232323232323232
I guess the whole purpose of having a f or a L for the floating literal is to keep the precision, if we don't want to allocate that many exceeded spaces using a double a_variable.
I guess if this is the code
|
float a_= numberL; // with suffix L
|
The compiler first temporary stores number in a long-double precision and then when we cout a, we are getting the float (single-precision) form of number, which some of the digits are loss.
Am I correct?
If it is, how does the pc stores that temporary precision?