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

Achim Gratz Stromeko@nexgo.de
Sun Jun 13 09:42:38 GMT 2021


Pavel M via Cygwin writes:
> 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

You will want to report this against newlib, I'd think.  If I remember
correctly, newlib uses a single guard digit for the conversion and for
such an algorithm the result you see is expected and correct.  Whether
any later C standard would mandate to use an algorithm that uses higher
precision (in terms of guard digits you'd end up with 15 for your
example before you get the expected result I think) I have no idea.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada


More information about the Cygwin mailing list