Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: bcd arithmetic
Posted:
Jun 15, 1996 7:59 PM


In article <4ppa96$gjc@math.mps.ohiostate.edu>, Vidhyanath K. Rao <vidynath@math.ohiostate.edu> wrote: > In article <4phmie$c0i@news.microsoft.com>, > Dann Corbit <acnadc@microsoft.com> wrote: >>This approach works in simplistic terms, for instance, when you are adding >>two amounts. But how do you figure tax using only integers? If you >>use only integer types, how do you figure interest, which is an exponential? >>You are back to using floating point in either case, which never eliminates >>the problem. > > The answer, used by FORTH, is to a new operation */ which computes > (a*b)/c, returning the quotient and remainder, with a*b kept in > double length format. > > The trouble with floating most people complain about is due to the fact > that the mantissa has fewer bits/digits than fixed types taking up > the same amount of memory. Floating point is used for calculations > not due to inherenet superiority, but due to the fact that highly > tuned floating point units are common, while typical ALU's do not make > such things as */ operations easy to implement. One ALU where this is easy to implement is the ALU in the Intel 80x86 series of CPU's, where the machine instruction for integer multiply leaves a doubleprecision result, and the instruction for integer divide expects a doubleprecision numerator to be divided by a singleprecision denominator. Thus an 8x8 bit multiply leaves a 16bit product, a 16x16 bit multiply leaves a 32bit product (in two 16bit CPU registers) and a 32x32 bit multiply leaves a 64bit product (in two 32bit CPU registers). The division can then divide this doubleprecision integer result with some singleprecision number.   Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF) Grev Turegatan 40, S114 38 Stockholm, SWEDEN email: pausch@saaf.se psr@home.ausys.se



