Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site desint.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcrdcf!trwrb!desint!geoff From: geoff@desint.UUCP (Geoff Kuenning) Newsgroups: net.lang.c Subject: Re: C needs BCD -- why BCD? Accountants! Message-ID: <222@desint.UUCP> Date: Sat, 17-Nov-84 19:11:39 EST Article-I.D.: desint.222 Posted: Sat Nov 17 19:11:39 1984 Date-Received: Mon, 19-Nov-84 03:24:07 EST References: <105@ISM780B.UUCP> <869@ihuxn.UUCP> <904@umcp-cs.UUCP> <4611@utzoo.UUCP> Organization: his home computer, Thousand Oaks, CA Lines: 21 > I have always been surprised that business people didn't just use 64 > bit integers, and keep the amounts in CENTS. No BCD required, can > take advantage of nice fast machine instructions, etc. Primarily because there are *still* relatively few machines that have good support for 64-bit integers. The average 32-bitter has 32x32 multiply that produces 64 bits, and a corresponding 64/32 divide, but other 64-bit math has to be implemented with "add with carry" instructions. If I recall correctly, the 360 didn't even have such an instruction, so you really had to hack it. The 2-3 instruction sequences needed to perform 64-bit arithmetic are not really more efficient than single BCD instructions. Furthermore, many business programs (e.g., general ledger or accounts receivable update) have a general model of "read in two fields, add them, write it out". You can do a BCD add *much* faster than you can do two conversions and a 64-bit binary add. Remember that decimal conversion inherently involves multiplication and division. -- Geoff Kuenning First Systems Corporation ...!ihnp4!trwrb!desint!geoff