https://kotlinlang.org logo
#stdlib
Title
# stdlib
k

Klitos Kyriacou

07/06/2022, 9:19 AM
Would it make sense if
log(x, base)
took a default value of
E
for
base
so as to make
log(x)
work just as it does in Java, C, and most other languages, instead of requiring the base to be explicitly passed? It would also form a counterpart of
exp(x)
which already implicitly uses a base of
E
.
🤔 1
i

ilya.gorbunov

07/06/2022, 11:19 PM
For common bases we provide
log10
,
log2
, and
ln
(base E) functions.
I don't think it's correct to say that
exp(x)
uses
E
base implicitly because there's no way to make it use other base explicitly. There's
pow
function for raising to the power of arbitrary bases.
k

Klitos Kyriacou

07/07/2022, 8:14 AM
Thanks, I had forgotten about the
ln
function.
2 Views