Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!cmcl2!ccnysci!dan From: dan@ccnysci.UUCP (Dan Schlitt) Newsgroups: comp.lang.c Subject: Re: Contiguous Arrays Summary: Math of computer numbers Message-ID: <1388@ccnysci.UUCP> Date: 9 Mar 89 18:07:44 GMT References: <2508@ssc-vax.UUCP> <8943@alice.UUCP> <1828@valhalla.ee.rochester.edu> <9718@smoke.BRL.MIL> <7390@killer.DALLAS.TX.US> Reply-To: dan@ccnysci.UUCP (Dan Schlitt) Organization: City College Of New York Lines: 37 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@ccnysci City College of New York dan@ccnysci.bitnet New York, NY 10031 (212)690-6868