Array indexing vs. pointers...

Robert Firth firth at sei.cmu.edu
Tue Oct 18 03:16:01 AEST 1988


In article <1700 at dataio.Data-IO.COM> bright at 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.



More information about the Comp.lang.c mailing list