https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70235

--- Comment #16 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Created attachment 38090 [details]
> Updated patch correcting problem found by Dominique

With this updated patch and y = 643.125 and d=2, I get

-8pf18.2 y=              1.00
-7pf18.2 y=              1.00
-6pf18.2 y=              1.00
-5pf18.2 y=              1.00
-4pf18.2 y=              0.06
-3pf18.2 y=              0.64
-2pf18.2 y=              6.43
-1pf18.2 y=             64.31
0pf18.2 y=            643.12
1pf18.2 y=           6431.25
2pf18.2 y=          64312.50
3pf18.2 y=         643125.00
4pf18.2 y=        6431250.00
5pf18.2 y=       64312500.00
6pf18.2 y=      643125000.00
7pf18.2 y=     6431250000.00

while I get

-8pf18.2 y=              0.00
-7pf18.2 y=              0.00
-6pf18.2 y=              0.00
-5pf18.2 y=              0.00
-4pf18.2 y=              0.06
-3pf18.2 y=              0.64
-2pf18.2 y=              6.43
-1pf18.2 y=             64.31
0pf18.2 y=            643.12
1pf18.2 y=           6431.25
2pf18.2 y=          64312.50
3pf18.2 y=         643125.00
4pf18.2 y=        6431250.00
5pf18.2 y=       64312500.00
6pf18.2 y=      643125000.00
7pf18.2 y=     6431250000.00

Note that -5pf18.2 y= should be 0.01 if correctly rounded. The rounding error
comes from the addition of

+      precision += dtp->u.p.scale_factor;
+      if (precision < f->u.real.d)
+       precision = f->u.real.d;

in my patch.

Reply via email to