At 05:22 PM 3/18/99 +0100, you wrote:

>I was wondering how BASIC calculates LOG(x). Does it use a look-up table
>(would require massive amounts of memory), some sort of algorithm (would
>require massive amounts of CPU time), or some mixed method?

There must be using a way that requires only a little memory. There are
many math functions present in the math pack in the ROM, for example LOG,
EXP, SIN, COS, TAN, ATN. They can't all use large tables, there is simply
not enough space in a 32K ROM.

They might use Taylor sequences or a technique like that. Although it's not
fast (on a Z80), it results in compact code that needs no tables.

>I'm trying to speed up multiplication and division (in machinecode) by
>using the following:
>log(x) + log(y) = log(x*y)
>log(x) - log(y) = log(x/y)

You'll need an EXP function as well, to get from "log(x*y)" to "x*y".

>I calculated I'd need about 96kB for a look-up table with reasonable
>accuracy. Because log(256*256)=4.8164 I'd need 48164 x 2 bytes.

I don't understand that calculation.

By the way, there is not just a 10log, you could use 2log or ln (e-log)
instead.

>Although I don't mind wasting that much memory, there has to be a smarter
>way...

If you don't mind wasting memory, why not make a 256x256 table that
contains the result of x*y? It would take 128K, but it's fast. Although
slot switching would degrade the performance a bit.

Anyway, I don't think using logs will get your multiplications any faster.
Maybe it's a better strategy to cut down the number of multiplications you
need to perform?

I think that the fastest way of multiplying a large amount of numbers on
MSX would be to use a GFX9000. Think about that... ;)

Bye,
                Maarten


****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****

Reply via email to