18 Mar 11, 02:25AM
(This post was last modified: 18 Mar 11, 11:22PM by Yarukinasu.)
EDIT:
EDIT: This returns the common logarithm, log10 n, of a given n value, and n should be greater than zero. Binary logarithm can also be used: log2 n, and n should be greater than zero.
(17 Mar 11, 04:19AM)Viper Wrote: Is there a script for finding logs (common)?
[SELECT ALL] Code:
div=f = [ $arg1 = (divf (getalias $arg1) $arg2) ]
log10 = [ result (divf (log2 $arg1) (log2 10)) ]
log2 = [
tmpval = $arg1
tmpres = 0
while [ (< $tmpval 1) ] [
-=f tmpres 1
*=f tmpval 2 ]
while [ (>= $tmpval 2) ] [
+=f tmpres 1
div=f tmpval 2 ]
tmpfp = 1
while [ (>=f $tmpfp 0.000001) ] [
div=f tmpfp 2
*=f tmpval $tmpval
if (>= $tmpval 2) [
div=f tmpval 2
+=f tmpres $tmpfp ] ]
result $tmpres ]
EDIT: This returns the common logarithm, log10 n, of a given n value, and n should be greater than zero. Binary logarithm can also be used: log2 n, and n should be greater than zero.