Created
April 7, 2018 17:28
-
-
Save westc/25888e8e87e871c0648825cc6607954b to your computer and use it in GitHub Desktop.
Find the logarithm of a given number using the given base.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var log; | |
(function(CACHE_LOG_INVERSE_BASE) { | |
log = function(x, opt_base) { | |
opt_base = opt_base || Math.E; | |
return Math.log(x) | |
* ( | |
CACHE_LOG_INVERSE_BASE[opt_base] = CACHE_LOG_INVERSE_BASE.hasOwnProperty(opt_base) | |
? CACHE_LOG_INVERSE_BASE[opt_base] | |
: (5 / Math.log(Math.pow(opt_base, 5))) | |
); | |
}; | |
})({}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment