I rewrote the "by calc" section from the following site
http://www.emesys.com/BS2math3.htm
into a subroutine and ended up with the following
Result is the log value multiplied by 1000
Accuracy should be good enough for what you are doing.
If you want to know HOW it works, you need to read the text, i just rewrote it and it worked so i was happy.
AndrewCode:LogNo VAR WORD ' Number to get log of k VAR byte 'loop var X Var WORD 'temp for processing X1 var word 'temp for squaring LgX var word 'lg ( base 2 ) of y the mantissa cc var byte 'characteristic of log Lg var word 'log base 2 Log var word 'log base 10 Ln var word 'log base e '--------------------------------------------------- etc etc Logno = varX 'ie no to get result gosub getlog ' now ref to Lg, Ln or Log as reqd GetLog: cc = NCD LogNo - 1 X = LogNo << ( 15 - cc ) LgX = 0 for k = 14 to 0 step -1 X1 = X**X if X1.bit15 then lgx = lgx | ( dcd k ) 'set the bit X = X1 else X = ( X1 << 1 ) + 1 'shift er over endif next k lg = cc*1000 + ( lgx**20000/10 ) log = ( lg ** 19728 ) ln = ( lg ** 45426 ) return ---------------------




Bookmarks