Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!pt.cs.cmu.edu!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.c Subject: Re: Array indexing vs. pointers... Message-ID: <7377@aw.sei.cmu.edu> Date: 17 Oct 88 17:16:01 GMT References: <836@proxftl.UUCP> <3105@hubcap.UUCP> <1700@dataio.Data-IO.COM> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 23 In article <1700@dataio.Data-IO.COM> bright@dataio.Data-IO.COM (Walter Bright) writes: >Floating point code offers more opportunities: > o Try very hard to replace divides with other operations, as in: > x / 10 > with: > x * .1 No: since 10 is exactly representable and 0.1 is not, this change will very often introduce additional rounding error. > o Reorganize expressions to make the best use of compile-time > constant folding, since the compiler is not allowed to do that. Again no: the compiler is not allowed to make these changes for the simple reason that they change the results of the calculation. Many scientific programmers go to great pains to minimise rounding error; don't undo their work. General advice to a maintainer of "scientific" programs: do not TOUCH any floating-point code unless you know at least as much numerical analysis as its author.