* GCC error ?
@ 2002-06-07 0:54 Hans-Joachim.Schmidt
2002-06-07 5:35 ` Tim Prince
0 siblings, 1 reply; 2+ messages in thread
From: Hans-Joachim.Schmidt @ 2002-06-07 0:54 UTC (permalink / raw)
To: gcc
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
Hello,
there is a problem when I compute:
double x,y,d,e;
x=112.7;
y=120.0;
d=x/y-1;
e=x/y; e--;
d=0x1.70a3d70a3d711p-6 (output of %a format)
e=0x1.70a3d70a3d700p-6
and
d-e=0x1.1000000000000p-54
Does the output of 'd' and 'e' (in %a format) show that there is more than 1
bit difference ?
We use SuSE Linux 8.0 (i386) - Kernel 2.4.18-64GB-SMP on a Pentium III
(Coppermine).
Best regards
Achim Schmidt
<<comp_diff.c>>
[-- Attachment #2: comp_diff.c --]
[-- Type: application/octet-stream, Size: 313 bytes --]
#include <stdio.h>
main() {
double d,e,x,y;
x=122.7;
y=120.0;
d=x/y-1;
printf("d=x/y-1= %a (%17.15e)\n",d,d);
e=x/y;
e--;
printf("e=x/y; e=e-1=%a (%17.15e)\n",e,e);
printf("d-e= %a (%17.15e)\n",d-e,d-e);
printf("x/y-1-e= %a (%17.15e)\n",x/y-1-e,x/y-1-e);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: GCC error ?
2002-06-07 0:54 GCC error ? Hans-Joachim.Schmidt
@ 2002-06-07 5:35 ` Tim Prince
0 siblings, 0 replies; 2+ messages in thread
From: Tim Prince @ 2002-06-07 5:35 UTC (permalink / raw)
To: Hans-Joachim.Schmidt, gcc
On Friday 07 June 2002 00:40, Hans-Joachim.Schmidt@bmf.bund.de wrote:
> Hello,
>
> there is a problem when I compute:
>
> double x,y,d,e;
>
> x=112.7;
> y=120.0;
>
> d=x/y-1;
> e=x/y; e--;
>
> d=0x1.70a3d70a3d711p-6 (output of %a format)
> e=0x1.70a3d70a3d700p-6
>
> and
> d-e=0x1.1000000000000p-54
>
>
> Does the output of 'd' and 'e' (in %a format) show that there is more than
> 1 bit difference ?
>
> We use SuSE Linux 8.0 (i386) - Kernel 2.4.18-64GB-SMP on a Pentium III
> (Coppermine).
>
>
It looks as if the division in the first expression has been rounded only to
64-bit precision, while the value of e has been rounded again to 53-bit
precision before being decremented. This would be an expected behavior, in
the absence of any instructions by you to the contrary. There was a thread
on this earlier this week, how the choice of precision mode mode is the
responsibility of the library, not gcc.
--
Tim Prince
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-06-07 12:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-07 0:54 GCC error ? Hans-Joachim.Schmidt
2002-06-07 5:35 ` Tim Prince
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).