http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49048
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-19
06:08:50 UTC ---
printf in glibc rounds, I think you should read something about rounding.
The default rounding mode (and the only one actually implemented for printf) is
round to even. http://www.lmgtfy.com/?q=round+to+even
So
#include <stdio.h>
int
main (void)
{
printf ("%.2f\n", 5798.12500);
printf ("%.2f\n", 5798.87500);
return 0;
}
printing
5798.12
5798.88
is correct.