[comp.lang.c] C and rf

dsill@NSWC-OAS.arpa (04/10/87)

Dan Hoey wrote:
>No, it says that for the purposes of C, the floating-point
>operations are ``commutative and associative'' and may be
>reordered.  If you want to object to K&R's redefinition of a term
>that has a well-defined mathematical meaning, object away, but
>that's what they did.

Well, I can't find anything in K&R that *explicitly* defines floating
point ops to be commutative and associative.  My point is this, since:
  - floating point operations in general are not commutative and
    associative,
  - a new C standard is being developed, and
  - everyone who uses C for numerical programming is bothered by the
    current approach,
shouldn't we be trying to decide what the *right* behavior is so it can
be considered for inclusion in the standard?  By "right" I mean the most
correct.  K&R allowed reordering expressions under the assumption
that the operations are commutative and associative and the reordering
would have *no effect on the result of the expression*.  However, there is
a BIG difference between real arithmetic and floating point arithmetic that
was entirely ignored by K&R.

I'm all for allowing the compiler to do its stuff, reorganizing and
optimizing away, but I also want to be able to predict the results of an
expression and/or program.

-Dave Sill
 dsill@nswc-oas.arpa