Fwd: gcc 11.1.0: printf("%.43f\n", 0x1.52f8a8e32e982p-140): printed value is incorrectly rounded

Pavel M pavel.morozkin@gmail.com
Wed Nov 3 21:26:16 GMT 2021


---------- Forwarded message ---------
From: Pavel M <pavel.morozkin@gmail.com>
Date: Sat, 12 Jun 2021 at 23:45
Subject: gcc 11.1.0: printf("%.43f\n", 0x1.52f8a8e32e982p-140): printed
value is incorrectly rounded
To: <cygwin@cygwin.com>


Sample code (t903.c):
#include <stdio.h>
int main(void)
{
    printf("%.43f\n", 0x1.52f8a8e32e982p-140);
    return 0;
}

Invocations:
# gcc on Windows 10 (Cygwin)
$ gcc t903.c -Wall -Wextra -std=c11 -pedantic -Wfatal-errors && ./a.exe
0.0000000000000000000000000000000000000000010

$ gcc --version
gcc (GCC) 11.1.0

# gcc on Linux
$ gcc t903.c -Wall -Wextra -std=c11 -pedantic -Wfatal-errors && ./a.exe
0.0000000000000000000000000000000000000000009

# clang on Windows
$ clang t903.c -Wall -Wextra -std=c11 -ffp-model=strict -pedantic
-Wfatal-errors && ./a.exe
0.0000000000000000000000000000000000000000009

# cl on Windows
$ cl t903.c /std:c11 /Za /fp:strict && ./t903.exe
0.0000000000000000000000000000000000000000009


More information about the Newlib mailing list