Web lists-archives.com

[Mingw-users] msvcrt printf bug

I encountered a loss of precision printing a float with C printf.
For values greater than or equal to 1.743397235870361328125 * 2 ^ 59 (0x5D5F27A4) the printed value is slightly wrong. The error increases with increasing input.
I attached a sample C file.
I tested against glibc 2.2.5 and against my own float to string.
The bug is in msvcrt. My msvcrt version is 7.0.7601.17744, crc32: DAB48B3A
mingw version: 4.0; gcc version: 5.3.0
Can anyone please confirm this?
I am sorry if this was posted before, I couldn't find anything.

Securely sent with Tutanota. Claim your encrypted mailbox today!
#include <stdio.h>
#include <stdint.h>

int main(void){
	union {
		float f;
		uint32_t u32;
	} fun;

	fun.u32 = 0x5D5F27A3;
	printf("%f, should be:\n1005000013434060800.000000\n", fun.f);	// prints correct

	fun.u32 = 0x5D5F27A4;
	printf("%f, should be:\n1005000082153537536.000000\n", fun.f);	// prints 1005000082153537500.000000 with msvcrt 7.0.7601.17744

	return 0;
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe