Rearranging FP expressions

wsmith at m.cs.uiuc.edu wsmith at m.cs.uiuc.edu
Mon Sep 26 11:56:00 AEST 1988


I realize this topic has been beat to death and its probably too late
for the ANSI C committee to do anything about it, but here's a suggestion
anyway.

The problem:  How can C know when it is safe to rearrange expressions,
		especially floating point expressions.

A proposed solution:
	Expressions enclosed in double parentheses may not be rearranged,
	all other expressions may be rearranged in "semantically valid"
	ways.

	foo = (a + b - c + d);   /* can be rearranged */

	foo = ((a + b - c + d)); /* cannot be rearranged */
	foo = a + ((b - c)) + d; /* c must be subtracted from b, but otherwise
			 	    this may be rearranged. */

Does this satisfy the requirements of the problem and also meet the needs of
both numerical analysts and bit-twiddlers?

Bill Smith
wsmith at cs.uiuc.edu
uiucdcs!wsmith



More information about the Comp.lang.c mailing list