I need to implement an logarithm function on an 18F part that executes as quickly as possible. Essentialy I need to convert power in nW to dBm with an resolution of 0.01dBm. i.e. 1E6nW (1mW) would return a value of 100 (1dBm). Both input and output of the function are 24bit integers. An interpolated table (like Scott Dattalos example) is the obvious choice, but I wondered if there was an alternative? Calculating the integer portion of a number in LOG base 2 is trival, it's simply the bit position of the most singificant bit which is set. Can this be extended to the the lower bits to get more accuracy? If so my equation boild down to LOG2(nW) * 301.03 - 6000, obviously the constants will have to be scaled to suit the fixed point output of the LOG2 function. Thanks for any assistance with this. Regards Mike Rigby-Jones ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist