Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!uwvax!oddjob!tank!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!m.cs.uiuc.edu!wsmith
From: wsmith@m.cs.uiuc.edu
Newsgroups: comp.lang.c
Subject: Rearranging FP expressions
Message-ID: <4700017@m.cs.uiuc.edu>
Date: 26 Sep 88 01:56:00 GMT
Lines: 25
Nf-ID: #N:m.cs.uiuc.edu:4700017:000:806
Nf-From: m.cs.uiuc.edu!wsmith    Sep 25 20:56:00 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@cs.uiuc.edu
uiucdcs!wsmith