Path: utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!hanami!landman From: landman%hanami@Sun.COM (Howard A. Landman) Newsgroups: comp.sys.mac.hypercard Subject: Re: Can there be such things as simple XCMD/XFCNs? Message-ID: <70425@sun.uucp> Date: 27 Sep 88 18:27:07 GMT References: <9468@cup.portal.com> Sender: news@sun.uucp Reply-To: landman@sun.UUCP (Howard A. Landman) Organization: Sun Microsystems, Mountain View Lines: 23 In article <9468@cup.portal.com> Lou@cup.portal.com writes: >P.S.: Anyone know why the round function rounds UP for fractions = .5 >if the whole part of the number is odd, but rounds DOWN for fractions >equal to .5 if the whole part of the number is even? For example, >round(1.5) is 2, but round(4.5) is 4. The IEEE floating point standard specifies that rounding must be done in this way. The motivation is to avoid bias in rounding, that is, you don't want rounding to have the property that rounding a random number has a different expectation than the random number itself. The rounding toward even numbers prevents this, since half the .5's round up while the other half round down, and has the side benefit that it leaves a zero in the LSB so that future operations (like divide by two) have a tendency to be a hair more accurate. It also has the advantage that positive and negative numbers round identically, that is, it is always true that round(-x) = -round(x). You can reconstruct the "old-style" rounding, if you must, by adding .5 and then truncating. Fair enough? Howard A. Landman landman@hanami.sun.com UUCP: sun!hanami!landman