log

Find the logarithm of argument x with the base of a

log<return_type>(a, x);

will return the logarithm of the argument x with the base a, both given as arguments. The return_type specifies in which data type the result will be returned in, like shown in below example:

log<int>(20, 400); //2
log<float>(1.43, 543.18); //17.6066

Because the ln(x) function is so precise, we can just use the:

loga(x)=ln(x)ln(a)log_a(x) = \frac{ln(x)}{ln(a)}

formula to calculate the given logarithm.

Last updated