[Bug middle-end/107370] long double sqrtl constant folding is wrong
jacob at jacob dot remcomp.fr
gcc-bugzilla@gcc.gnu.org
Mon Oct 24 20:51:51 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107370
--- Comment #16 from jacob navia <jacob at jacob dot remcomp.fr> ---
Sorry but the program I used was compiled with gcc. It suffers from lack of
precision too.
In ANY case, in decimal now, the square root of 2 is
1.414 213 562 373 095 048 801 688 724 209 698 078 GP PARI calculator
1.414 213 562 373 095 145 547 462 185 874 gcc: only the first 15 digits are OK
^^^^^
In ANOTHER example:
#include <stdio.h>
#include <math.h>
int main(void) { printf("%.30Lg \n",sqrtl(powl(2,225))); }
This produces:
7.34301663720716943338259962711e+33
But bc produces
~/lcc/book/test % bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale=32
sqrt(2^225)
7343016637207168931428032607349397.48923080385562326502615381523522
To make things clearer I put now the results side by side
7.34301663720716943338259962711e+33 gcc
734301663720716 8931428032607349397.48923080385562326502615381523522 bc
As you can see, after the 15th digits all others are wrong!!!
Jacob
More information about the Gcc-bugs
mailing list