Mail Archives: djgpp/1996/01/30/02:30:39
On Mon, 29 Jan 1996, Axel Thimm wrote:
> c = quad(a);
> cout << (b - c) << '\t';
> cout << (b - a*a) << '\t';
> cout << (c - quad(a)) << '\n';
[snip]
> digits, but I cannot understand what happens with c! Both times a
> function is called, that _is_not_ inlined, so in both cases the same
> loss of digits should be observed.
Look at the machine code generated by GCC. Most probably, the result of
`quad' is stored in c to lose some precision. When c - quad(a) is
computed, the compiler doesn't bother to store the result of `quad', but
instead leaves it on the stack of the FPU and just subtracts it from c.
You then see how much did you lose by using a float (a relative precision
of 1e-7 is usually all you can rely on with floats; use double for twice
as much significant digits).
If you want to make this ``feature'' go away, try using the -ffloat-store
switch to GCC. It's described in the GCC docs.
- Raw text -