Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!mailrus!ncar!tank!oddjob!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical analysis Message-ID: <13570@mimsy.UUCP> Date: 15 Sep 88 05:26:00 GMT References: <893@amelia.nas.nasa.gov> <3064@lanl.gov> <820@cernvax.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 28 In article <820@cernvax.UUCP> hjm@cernvax.UUCP (Hubert Matthews) writes: >Consider the following cases: > > I = (5 / 4) * 5 (I gets 5) > > I = 5 / (4 * 5) (I gets 0) > > I = 5 / 4 * 5 (I gets 5 in F77, I gets something in C) I gets 5 in C (even in K&R 1st ed. C). The arithmetic operators group left-to-right, and while The order of evaluation is not specified for associative and commutative operators like * and + (K&R 1st ed., p. 37), the divide operator is hardly commutative! >Evaluation order is important, and parentheses are the most obvious way of >expressing it. Temporary variables are a hack. Sometimes (many people will break up ten-line expressions for the sake of clarity). Nonetheless, there are two problems being solved: overriding the default groupings, and specifying order of operation. Any time you use a single solution for two (or more) orthogonal problems, you have missed out on some potential orthogonality. (Whether it would in fact be *useful* is a different argument entirely.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris