From the document you linked
Returns the logarithm of |x|, using FLT_RADIX as base for the
logarithm.
On most platforms, FLT_RADIX is 2, and thus this function is
equivalent to log2 for positive values.
So you just need to compute whats the log2(|x|)
.
Math.log(Math.abs(x))/Math.log(2)
Logarithmic functions have a base, the most common one is 10 since we work in a base 10 numeric system. Common bases for computers is a base 2 since it works in a binary system. Converting bases can be simply done by working with this formula.
Logb(x) = Logv(x) / Logv(b)
Simply take the Log(x)
in any base you want (10 for instance) and divide it by the Log(b)
.
Heres a relevant link about it:
http://www.mathwords.com/c/change_of_base_formula.htm
https://www.khanacademy.org/math/algebra2/exponential-and-logarithmic-functions/change-of-base-formula-for-logarithms/a/logarithm-change-of-base-rule-intro
You might right a function like:
// get the log value of x using base b
function logb(x, b) {
return Math.log(x)/Math.log(b);
}