[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: info-mcl@cambridge.apple.com*Subject*: Re: weird math*From*: jwbaxter@pt.olympus.net (John W. Baxter)*Date*: Thu, 26 Aug 1993 18:23:47 -0700

What we see in this thread is yet another periodic revelation that binary floating point doesn't work well in a decimal world. It really isn't the right way to represent lots of things. US money, for example. I believe that what follows is a list of the numbers of cents (expressed as decimal parts of a dollar) which represent exactly in binary floating point of ANY precision: (.00, .25, .50, .75) (or 4% of the possible values). This is the basic reason why Apple extended the IEEE standard with the SANE comp (computational) type. Money can be recorded precisely in 100ths (or, perhaps better, 1000ths) of dollars in a comp, quite nicely. [A simple 64-bit integer and the related math might have been even better, saving the conversions to (exact) floating point representations for all operations, and back to comp for storage. If you see a binary floating point system in which you DON'T see these comparison oddities, you're working with one which does fuzzy compares for equal. All that really accomplishes is to give the programmer a false sense of exactness where there is not exactness. -- jwbaxter@pt.olympus.net (John W. Baxter) AppleLink BAXTER.JOHN if you really must (but ONLY from AppleLink). CIS 71735,1626

- Prev by Date:
**Accessing C floating point data type in MCL** - Next by Date:
**new version of SYMBOL-COMPLETE uploaded** - Previous by thread:
**Re: weird math** - Next by thread:
**interface file for speech manager** - Index(es):