You have specified that 20 digits after the decimal point should be printed. And so they are. But that does not mean that these digits are correct and meaningful.
You have also noticed that the last four digits are zeroes. That is because a
has that precision and the additional digits are set to zero by the
The reason that both printed values have these 16 digits is sourced by the fact that the
function only supports
values as floating point arguments and passed
arguments are converted to
behind the scenes. The compiler is processing it as:
printf("float = %.20f \n", (double)f);
The resulting values printed with appropriate resolution are:
input = 3.1415926535897932384626433832795
double = 3.14159265358979311
float = 3.141592741
As you can see the
differs from the input at the 8th digit and the
at the 17th digit.