Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site lanl-a.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!cmcl2!lanl-a!jlg From: jlg@lanl-a.UUCP Newsgroups: net.physics Subject: Fortran vs. C Message-ID: <10309@lanl-a.UUCP> Date: Thu, 12-Jul-84 13:07:15 EDT Article-I.D.: lanl-a.10309 Posted: Thu Jul 12 13:07:15 1984 Date-Received: Sat, 14-Jul-84 01:01:54 EDT Organization: Los Alamos National Laboratory Lines: 18 >C explicitly does NOT rearrange most arithmetic operations >(exceptions are supposedly commutative operators). That's not the problem. C rearranges 'supposedly' associative operations, even when the expression has been parenthesized to prevent it. For example: a = b + (c + d); The C compiler may (and frequently does) do (b+c)+d or (b+d)+c instead of b+(c+d). Since floating point addition is NOT associative, the two rearrangements may give incorrect answers. The problem is magnified when there is a large expression to be compiled with several non-associative adds present -- often the result from C is completely unpredictable. This is probably one of the reasons that ALL C arithmetic is double precision, i.e. so that bad instruction scheduling won't be noticed as often. J.L.Giles ...inhp4!cmcl2!lanl-a!jlg