Re: [stella] Polar to Cartesian Co-Ordinate Converter

Subject: Re: [stella] Polar to Cartesian Co-Ordinate Converter
From: Chris Wilkson <ecwilkso@xxxxxxx>
Date: Mon, 22 Oct 2001 13:25:39 -0400 (EDT)
On Mon, 22 Oct 2001, Chris Wilkson wrote:

> > Especially the fast division may open some new opportunites. To bad, that I can't use them for my new demo, since I need the remainder too :-(
> > You don't know a formula for this, do you?
>
> Ummmm...I'm not sure what your question is.  If you take your log tables out
> far enough (enough digits, that is)  You'll get frational answers.
>
> I.e.  (assuming base 10 log tables)
>
> If log(128) = 2.10720997 and log(7) = 0.84509804 then 128/7 = 18.2857143.
> If log(128) = 2.10720 and log(7) = 0.84509 then 128/7 = 18.28563304
> If log(128) = 2.10 and log(7) = 0.84 then 128/7 = 18.19700859
>
> I think you should just be able look at the most significant n-bits for
> the quotient and the rest is the remainder.

Adding to my own rambling....

Assume that I define my numbers as 8-bit.8-bit.  If I do the above division
(128/7)  it looks like the following:

128   = 10000000.00000000
7     = 00000111.00000000
128/7 = 00010010.01001001 = 18.28515625, which is truncated, but pretty close

Now, if you only look at the integer bits, you get 00010010, or 18.
If you multiply by the divisor, 7, you get 126.  Subracting this from the
dividend, 128, gives the remainder which is 2.

Or, if you only look at the fractional bits, you get 01001001, or .28515625.
If you multiply this by the divisor, 7, you get (almost) 2.

In summary/ pseudo code:  (if a/b = int(a/b) + r = q + r)

x = log(a) - log(b)
q = int(antilog(x)) ;  = int(10^x)
x = log(b) + log(q)
x = int(antilog(x)) ;  = int(10^x)
r = a - x


-Chris


-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread