Does Swift has built-in logarithm function?
You can use the log2(:Double) or log2f(:Float) methods from the documentation, available by e.g. importing UIKit or Foundation: func log2(x: Double) -> Double func log2f(x: Float) -> Float E.g., in a Playground print(log2(8.0)) // 3.0 (Edit addition w.r.t. your comment below) If you want to compute your custom-base log function, you can make use of … Read more