andrew@orca.UUCP (Andrew Klossner) (11/14/84)
[Start this line at column one or the paranoids will get you] "I fail to see the need for bcd arithmetic even in business computing ... bcd arithmetic is slower than binary arithmetic: even with special bcd hardware, still more memory accesses are required to get all the data into the alu and to write out the result." This is true only if all numbers are integers, which is usually not the case in commercial programming. Consider the addition of two numbers, one with no digits after the decimal point and the other with two digits after the decimal point. (In PL/I, these are FIXED DEC(10,0) and FIXED DEC(10,2), perhaps.) If you store these in binary, to do this simple addition you must multiply the first number by 100. In BCD, multiplication by a power of ten is a simple shift, much faster. Another example: multiplication of two numbers, each with two digits after the decimal point. This produces a number with four digits after the point. If stored in binary, you fix it by dividing by 100. BCD can do it with a multiply and a shift, binary requires a multiply and a divide. Not that this should have anything to do with the C language. You shouldn't try to teach a pig to dance; it frustrates you and upsets the pig. -- Andrew Klossner (decvax!tektronix!orca!andrew) [UUCP] (orca!andrew.tektronix@rand-relay) [ARPA]