Re: gcc 11.1.0: printf("%.43f\n", 0x1.52f8a8e32e982p-140): printed value is incorrectly rounded
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
On Nov 4 00:26, Pavel M wrote: > ---------- Forwarded message --------- > From: Pavel M <[email protected]> > 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: <[email protected]> > > > 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 Newlib's ldtoa implementation is lacking. It's using an algorithm which defines an upper bound of digits to return to the caller, and currently the number of digits is retricted to 42. I was able to raise the max number of digits to 1023 in Newlib's ldtoa, and I'm going to push the patch in a bit. However, a much better fix would be to switch to gdtoa, as the BSDs and Mingw64 do. Is anybody here willing to take a look and change Newlib to gdtoa? Thanks, Corinna