lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Oct 18, 2021 at 9:15:53 AM, Flyer31 Test <> wrote:

do you possibly some "most easy way" proposal, if I want to replace
the exponentiation by some "own calculation"?

(my STM32G473 controller has a so-called CORDIC interface for
high-speed calculation of sin, cos, tan, exp, log, sqrt on board, so I
want to use this for my Lua.

Using logarithmic identities, you can change b ^ x to K ^  (x * logK(b))
It looks more complicated, but if K is a convenient value, such as 2 or 10 or e, it becomes much easier.
For example, if K is e, then b ^ x = exp(x * ln(b))
If you have exp and ln in your library, you’re in luck, though you may need to deal with some edge cases.