1. Using%f to output real numbers, only 6 decimal places can be obtained.
Program:
#include <stdio.h>
int Main ()
{
Double A = 1.0;
printf ("%f\n", A/3);
return 0;
}
Results:
0.333333
Please press any key to continue ...
The number of significant digits of the 2.float type data.
Program:
#include <stdio.h>
int Main ()
{
float A;
A = 10000/3.0;
printf ("%f\n", a);
return 0;
}
Results:
3333.333252
Please press any key to continue ...
Note: Since the float type data has only 6 valid digits, the program starts from the seventh position on the left, and the following numbers are not guaranteed to be absolutely correct.
This article is from the "Rock Owl" blog, please be sure to keep this source http://10742111.blog.51cto.com/10732111/1718370
C language: Output real numbers with%f, only 6 decimal places and the number of valid digits for float type data