Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!bu.edu!purdue!sage.cc.purdue.edu!ar4 From: ar4@sage.cc.purdue.edu (Piper Keairnes) Newsgroups: comp.sys.mac.programmer Subject: Re: Why can't the Mac add? Message-ID: <4485@sage.cc.purdue.edu> Date: 23 Sep 90 02:05:47 GMT References: <45060@apple.Apple.COM> Organization: Purdue University Lines: 32 In <45060@apple.Apple.COM> das@Apple.COM (David Shayer) writes: >I was running this simple program. >main () >{ > float x; > > for (x=0.0;x!=10.0;x+=0.2) > printf ("x=%f \n",x); >} That isn't that simple of a program when dealing with floating point numbers. There is no such thing as an EXACT floating point number. Floating point numbers are close approximations to real numbers. In Mathematics, real numbers are infinitely accurate, eh? Well, machines are finite. Each 32 or 64 bits of a computer can store a number only so accurately. You start off at a number near 0 and add a number near 0.2 and expect the computer to end when the number is near 10. If that is your wish, then just set your conditional to 'x <= 10.0' It is not that the Mac is poor at Math. In fact, in a recent homework for one of my Numerical Analysis classes, we had to approximate a function with a polynomial. My Mac SE, without math co-processor, got the exact same answers as did a 10 by '386 processor Sequent Symmetry with math co-processors. So don't blame Apple... blame either your code, or the people who designed finite machines ;-) _____ Piper Keairnes - Computer Science ** Purdue University Computing Center ** INTERNET: ar4@sage.cc.purdue.edu ** Unisys Corporation Co-op Student ** BITNET: xar4@purccvm.bitnet ** Macintosh Programmer/ Specialist **