Microsoft KB Archive/29557

= printf Default Floating-Point Precision Is 6 Decimals =

Article ID: 29557

Article Last Modified on 12/11/2003

-

APPLIES TO

 The C Run-Time (CRT), when used with:  Microsoft C Professional Development System 5.1

 Microsoft C Professional Development System 6.0

 Microsoft C Professional Development System 6.0a

 Microsoft C Professional Development System 6.0a</li></ul>

 Microsoft C Professional Development System 5.1</li></ul>

 Microsoft C Professional Development System 6.0</li></ul>

 Microsoft C Professional Development System 6.0a</li></ul>

 Microsoft C/C++ Professional Development System 7.0</li></ul>

 Microsoft Visual C++ 1.0 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Learning Edition</li></ul>

 Microsoft Visual C++ 2.0 Professional Edition</li></ul>

 Microsoft Visual C++ 4.0 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q29557

<div class="summary_section">

SUMMARY
By 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:

%[ ][ ][. ]

<div class="moreinformation_section">

MORE INFORMATION
The 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(&quot;%e\n&quot;, d); printf(&quot;%le\n&quot;, d); } This code example produces the following output: <pre class="fixed_text"> 1.234568e+000 1.234568e+000 To display the value d to its full precision, modify the code example to use the following statement: printf(&quot;%.15le&quot;, d);

Additional query words: kbinf 1.00 1.50 2.00 5.10 6.00 6.00a 6.00ax 7.00

Keywords: kbcrt KB29557

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.