Page 1 of 1

Change the base of Log() using second parameter

Posted: 04 Jun 2018, 12:55
by HakitoJin
Here is what I am currently using:

Code: Select all

LogBase(Number,Base=10)
{
	return Log(Number)/Log(Base)
}
It would be neat if the built-in version could do the same.

Re: Change the base of Log() using second parameter

Posted: 04 Jul 2018, 18:00
by jeeswg
- Great idea, this is what I'm currently using:

Code: Select all

JEE_Log(vNum, vBase:=10)
{
	if (vBase = 10) || (vBase = "")
		return Log(vNum)
	else if (vBase = "e")
		return Ln(vNum)
	else
		return Log(vNum)/Log(vBase)
		;return Ln(vNum)/Ln(vBase)
}
- Do you have much use for this? Which bases? I would use it mainly for base 2 in relation to audio e.g. here:
jeeswg's SoX (Sound eXchange) tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=29234
- I also thought that Floor/Ceil could handle a 2nd parameter, like Round does.
Floor/Ceil able to handle decimal places (cf. Excel's Trunc function) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=41539