Excel Log Equivilent To JS Math.log()
In my javascript code I have the following Math.log(20) = 2.995732273553991 In my excel formula I try to replicate this with =LOG(20) = 1.301029996 Anyone have any idea why I'm
Solution 1:
Math.log(20) is base e, while LOG(20) is base 10.
You're not looking for LOG(20), but probably rather LN(20) (base e).
MDN (for javascript) : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log
LN (for excel): https://support.office.com/en-us/article/LN-function-81fe1ed7-dac9-4acd-ba1d-07a142c6118f
The LOG Function you are using automatically set the second parameter to 10 if it is not set (default 10), as pointed out there:
From here: https://support.office.com/en-nz/article/LOG-function-4e82f196-1ca9-4747-8fb0-6c4a3abb3280
Solution 2:
Just in case anyone is interested in going the other direction: To get Excel's LOG(x) you can just do:
Math.log(x) / Math.log(10);
Or, being more efficient:
Math.log(x) / Math.LN10;
Post a Comment for "Excel Log Equivilent To JS Math.log()"