rs6000: floating point cast oddities?

Linus Torvalds torvalds@transmeta.com
Mon Dec 17 15:11:00 GMT 2001


On Mon, 17 Dec 2001, Richard Henderson wrote:
>
> I'd have thought there were possible double rounding issues,
> but a brute-force search across a problem range I suspected
> didn't yield any differences.

I thought that rounding _between_ operations was ok, as long as you do so
consistently.

For example, the solution to the basic non-IEEE'ness of the x87 extended
precision is to round after each and every operation, by just storing it
back to memory and re-loading. Yes, it double-rounds, but it always rounds
after each operation, and it rounds to the precision we want.

The non-IEEE nature we have right now on x86 is that we do _sequences_ of
operations with too much precision, not just one.

So while

	float + float = (float)((double) float + (double) float)

it does _not_ follow that you can do

	float + float + float = (float) ((double) float + (double) float + (double) float)

because doing two operations in double and then rounding only once is
different from doing them in float and rounding in between.

But I don't have _anything_ except my own recollection to substantiate
this rule.

Who's the IEEE expert?

		Linus



More information about the Gcc mailing list