implementation of logarithmic equations

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hey
i'm doing a project on digital communication wherein i need to implement some equation containing logarithmic function..for e.g.log(1+x)where x=input..
can anybody help..

[Your post suggests you can read/write English so I'm not sure why you weren't able to read the rules posted at the top of Academy Forum which would have told you this was the WRONG FORUM. I'll move this to a more appropriate forum though your second post doesn't make it clear whether you mean the 8bit ATmega32 or the 32 bit AVR32 architecture - I'll assume the latter. Moderator]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What language, which bit do you need help on? Also, what arch?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

c language..8 bit..atmega 32(RISC) architechture

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

High level solution:

include math.h and the like and just use log() function.

Low level solution:

Actually the binary numbers are "logarithmic" by nature: Log2(256) = 8, Log2(128) = 7 etc. Each bit position add 6 dB to the total so you can just loop trough the bit positions to find the integer part or "characteristic", then use a table lookup for the fraction or "mantissa":

http://en.wikipedia.org/wiki/Com...

Algorithm can be like this, using 8 bit table lookup for fraction part:

first_set_bit = 31; // MSB of unsigned int
if (input==0) return; // Log(0) error
while (input&(1<<first_set_bit)==0) first_set_bit--;
lookup_address = // the 8 bits following first_set_bit downwards
fraction_part = lookup(lookup_address);
integer_part = first_set_bit;

Of course the result must be scaled to fit the application, ie it is not scaled to mathematical log10().