printf() Default Floating-Point Precision Is 6 DecimalsLast reviewed: January 18, 1996Article ID: Q29557 |
|
The information in this article applies to:
SUMMARYBy default, the printf() function displays a floating-point number to six digits of precision. This default also holds for double precision numbers. To display additional digits of precision, specify a value for the precision field in the printf() format specification, as follows:
%[<flags>][<width>][.<precision>]<type> MORE INFORMATIONThe code example below demonstrates documented printf() behavior that may appear to be a problem with the function.
#include <stdio.h>
main()
{
double d = 1.2345678912;
printf("%e\n", d);
printf("%le\n", d);
}
This code example produces the following output:
1.234568e+000 1.234568e+000To display the value d to its full precision, modify the code example to use the following statement:
printf("%.15le", d);
|
Additional reference words: kbinf 1.00 1.50 2.00 5.10 6.00 6.00a 6.00ax
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |