Visual Studio and .NET Framework Home
printf/sprintf do not print enough significant digits for exact binary fractions
as Won't Fix
2/19/2008 5:53:06 PM
User(s) can reproduce this bug
Fractions expressible as a/2^n have exact binary representations (with n, for example, being <= 53 for the double type). I would expect printf and sprintf to print out all n digits of such fractions as they are all significant. As the attached program shows, (2^24+1)/2^25 = 0.5000000298023223876953125, but printf gives 0.5000000298023223900000000.
Visual Studio 2008 (All Products and Editions)
Windows XP Home Edition
Operating System Language
Steps to Reproduce
value = 16777217/33554432.0; //=(2^24+1)/2^25 = 0.5000000298023223876953125
printf ("%1.25f",value); //Prints 0.5000000298023223900000000
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 7/6/2009 at 11:32 AM
Thx super for the extra info! As we said, we will look into this for the release after VS2010.
VC++ Dev Lead
on 1/30/2009 at 2:12 PM
When you fix this, consider that the new limit should be no less than 1074. This will allow you to print any dyadic fraction to full precision, even all 1074 digits of 2^-1074. GCC C allows this.
I wrote an article about how VS C++ and 7 other languages handle this issue at http://www.exploringbinary.com/print-precision-of-dyadic-fractions-varies-by-language/
on 12/30/2008 at 4:09 PM
The Visual C++ team has triaged the issue you reported. The issue has been resolved during triage with the following message:
Thanks for reporting this problem. We're aware of it, and we don't have time to fix this issue for the next release of VS (VS 2010).
The problem is that we need to refresh the read/write floating point algorithms. We'll do that in the release after VS 2010.
For further information, you may want to consult one of these resources:
1. Visual C++ triage guidelines:
2. MSDN forums:
Thank you for taking time to send us feedback,
The Visual C++ Team
on 2/19/2008 at 6:54 PM
Thanks for your feedback. We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
© 2014 Microsoft