EmbeddedRelated.com
Forums

Logarithm on a PIC

Started by Louis Nel April 6, 2004
I have been searching high and low for the assembly language code to
determine the log base two of a sixteen bit floating point number
smaller than one.

Has anybody had any luck? The AN660 from microchip is very
complicated. The closest I came is the routine by Nikolai Golovchenko
at piclist (
http://www.piclist.com/techref/postbot.asp?by=time&id=piclist/2000/09/28/080926a&tgt=&key=log2&from=
) It does not seem to work with numbers bigger than 0.5(decimal).

Try 0,999999999 for instance and you get a number bigger than one. Any
help will be appreciated.

Louis


I have been searching high and low for the assembly language code to
determine the log base two of a sixteen bit floating point number
smaller than one.

Has anybody had any luck? The AN660 from microchip is very
complicated. The closest I came is the routine by Nikolai Golovchenko
at piclist (
http://www.piclist.com/techref/postbot.asp?by=time&id=piclist/2000/09/28/080926a&tgt=&key=log2&from=
) It does not seem to work with numbers bigger than 0.5(decimal).

Try 0,999999999 for instance and you get a number bigger than one. Any
help will be appreciated.

Louis


"Louis Nel" <louisn@iafrica.com> wrote in message
news:40731b5c.98380031@ct-news.iafrica.com...
> I have been searching high and low for the assembly language code to > determine the log base two of a sixteen bit floating point number > smaller than one.
Is this your own floating point representation? What accuracy do you need in the final result? How much ROM and RAM can you devote? How much time can you spare? Which PIC are you using?
> > Has anybody had any luck? The AN660 from microchip is very > complicated. The closest I came is the routine by Nikolai Golovchenko > at piclist ( >
http://www.piclist.com/techref/postbot.asp?by=time&id=piclist/2000/09/28/080 926a&tgt=&key=log2&from=
> ) It does not seem to work with numbers bigger than 0.5(decimal). > > Try 0,999999999 for instance and you get a number bigger than one. Any > help will be appreciated. > > Louis
I haven't ready the app note but it appears to be a floating point library for IEEE 754 (32 bit floating point). If you really need floating point, why not use a processor that has (at least) a multiply instruction? How about one that has an add with carry instruction ;-) Bob
ofcourse in JAL ;-)
here's an integer algoritme
   http://oase.uci.kun.nl/~mientki/PIC/Projects/PIC_math_log.htm
there are also some links on the page
succes !
Stef Mientki

Louis Nel wrote:

> I have been searching high and low for the assembly language code to > determine the log base two of a sixteen bit floating point number > smaller than one. > > Has anybody had any luck? The AN660 from microchip is very > complicated. The closest I came is the routine by Nikolai Golovchenko > at piclist ( > http://www.piclist.com/techref/postbot.asp?by=time&id=piclist/2000/09/28/080926a&tgt=&key=log2&from= > ) It does not seem to work with numbers bigger than 0.5(decimal). > > Try 0,999999999 for instance and you get a number bigger than one. Any > help will be appreciated. > > Louis > >