Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: bcd arithmetic
Replies: 1   Last Post: Jun 15, 1996 7:59 PM

 Paul Schlyter Posts: 84 Registered: 12/7/04
Re: bcd arithmetic
Posted: Jun 15, 1996 7:59 PM

In article <4ppa96\$gjc@math.mps.ohio-state.edu>,
Vidhyanath K. Rao <vidynath@math.ohio-state.edu> wrote:

> In article <4phmie\$c0i@news.microsoft.com>,

>>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 double-precision result, and the instruction for integer
divide expects a double-precision numerator to be divided by a
single-precision denominator. Thus an 8x8 bit multiply leaves a
16-bit product, a 16x16 bit multiply leaves a 32-bit product (in two
16-bit CPU registers) and a 32x32 bit multiply leaves a 64-bit
product (in two 32-bit CPU registers). The division can then divide
this double-precision integer result with some single-precision
number.

--
----------------------------------------------------------------
Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40, S-114 38 Stockholm, SWEDEN
e-mail: pausch@saaf.se psr@home.ausys.se