Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdcad!amdahl!dgcad!gary From: gary@dgcad.SV.DG.COM (Gary Bridgewater) Newsgroups: comp.arch Subject: Re: Fast conversions, another urban Message-ID: <1155@svx.SV.DG.COM> Date: 6 Oct 89 07:08:57 GMT References: <4125@cbnewsh.ATT.COM> <18000002@inmet> Reply-To: gary@svx.SV.DG.COM () Organization: Data General SDD, Sunnyvale, CA Lines: 35 In article <18000002@inmet> callen@inmet writes: > >/* Written 8:53 am Sep 22, 1989 by beyer@cbnewsh.UUCP in inmet:comp.arch */ >/* ---------- "Re: Fast conversions, another urban" ---------- */ >In article <136@bbxsda.UUCP>, scott@bbxsda.UUCP (Scott Amspoker) writes: >I have never done business-oriented calculations, but it seems to me, >as an outsider, that calculating everything in pennies solves the round-off >problems (but perhaps no others), doesn't it? This is the second posting to state this. Time to put on our thinking caps... Just because the current smallest denomination coin in general circulation is the penny - should that mean that commercial calculations are limited to that resolution? In fact it doesn't. The accuracy of a commercial calculation ( loan interest, savings interest, amortizations, etc.) is determined by some policy setting board with authority over that interest (IRS, FED, state banking commission). This is POLICY. Don't keep confusing Policy with 'seems to me' or 'what a real keen algorithm can do' or 'what a Big Mean computer can do'. If the policy says you keep 8 decimal places then that is what you do. What you want to do is compute using - wait for it - Float Decimal. Not Float Binary with a printf to fool the human into thinking you used decimal. With Float Decimal, if you divide 100 by 3 using 8 digits after the decimal point then you get 33.33333333. Two decimal digits to the left of the decimal point and eight after. You can now multiply by 3 and discover that you 'lost' .00000001 in the calculation. You will probably have to account for that later. That is why loan payments can be $100, $100, $100, $100.01. There is no such thing as round off error because you go back and fix the calculation to account for the error. (You don't usually see banks offering 8 1/3% interest, tho.) This isn't mathematics. It isn't scientific calculations. It's accounting. Bankers don't grok bits. -- Gary Bridgewater, Data General Corp., Sunnyvale Ca. gary@sv4.ceo.sv.dg.com or {amdahl,aeras,amdcad,mas1,matra3}!dgcad.SV.DG.COM!gary No good deed goes unpunished.