Jump to content
Sign in to follow this  
mnchartier

Logarithim Problem

Recommended Posts

mnchartier

Trying to create some small scripts for audio calculations and I am using the log function but it is not always correct. If you use the sample in the help file it comes out right but I am trying this

$Log1 = log(4)
$Log2 = log(8)
consolewrite ($log1)
consolewrite (@CRLF)
consolewrite ($log2)

and they do not come out correctly, they are coming out 1.38629436111989 and 2.07944154167984 respectively and they should be 0.6021 and 0.90309. Any one else use log and have similar problems?

Share this post


Link to post
Share on other sites
PsaltyDS

You didn't read the help file closely enough. The AutoIt log() function, and those of most programming languages, return the nautural log, or ln(x), or loge(x). You are looking for common log, or log10(x):

ConsoleWrite("log(4) = " & Log(4) & @LF)
ConsoleWrite("Log10(4) = " & Log10(4) & @LF)
ConsoleWrite("log(8) = " & Log(8) & @LF)
ConsoleWrite("Log10(8) = " & Log10(8) & @LF)

; user-defined function for common log
Func Log10($x)
    Return Log($x) / Log(10)  ;10 is the base
EndFunc   ;==>Log10

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
mnchartier

Thank you for the explanation and the example.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×