Contiguous Arrays

Dan Schlitt dan at ccnysci.UUCP
Fri Mar 10 04:07:44 AEST 1989


Please allow me to try to cut through all of this complicated
discussion of specific behavior of arithmetic for various data types
on sundry computers.  If one insists on thinking like a mathematician
then one must understand that the mathematical objects that we call
ints, floats, pointers, .... are special objects with peculiar
properties.  They simply are not the objects that we learned about in
elementary school.  Any expectations derived from our experience with
the natural numbers or the reals may be wrong.

They are finite sets.  They frequently are not closed under common
operations like "addition".  When they are closed the behavior may be
strange.

Most folk who deal with computers avoid this swamp by not thinking
like mathematicians.  They deal with the objects as they find them.
This generally keeps them out of trouble.  Most of the answers in this
thread have been of this sort.  They are correct answers, but they
don't satisfy the mathematician in us.

Even though my background is theoretical physics and quantum field
theory, I have never found the discussion of computer arithmetic as a
topic in abstract mathematics very attractive.  But if you are going
to do it then you have to do it right.  A good first step probably is
to stop using "+" and "-" as binary operators in the discussion.  Then
you won't be confused by the arithmetic of natural numbers.

This, of course, ignores all of the botches which have been imposed on
us by various designers.  W.M. Kahan didn't write the program called
paranoia just for fun.  The type of errors that it tests for actually
occur in the computer arithmetic of well known computers.  (The program
is available from netlib.)  Some examples are given in his paper in
Information Processing 71, North-Holland(1972).
-- 
Dan Schlitt                        Manager, Science Division Computer Facility
dan at ccnysci                        City College of New York
dan at ccnysci.bitnet                 New York, NY 10031
                                   (212)690-6868



More information about the Comp.lang.c mailing list