The log10()
function in Swift uses the base of 10 to calculate the logarithm of a number. The mathematical representation of the log10()
function is given below:
log10(number)
A
The logarithm of the given number is returned.
Let's look at the code below:
import Foundation// Using a positive integerprint ("log10(4.0) = ", log10(4.0));// Using a positive floatprint ("log10(4.4) = ",log10(4.4));// Using a value of 10print ("log10(10.0) = ",log10(10.0));// Using values which raise exceptionsprint ("log10(-4.5) = ",log10(-4.5));print ("log10(0.0) = ",log10(0.0));
Foundation
header required to use the log10()
function.log10()
function to calculate the logarithm with base 10 of a positive integer.log10()
function to calculate the logarithm with base 10 of a positive float.log10()
function to calculate the logarithm with base 10 of the number 10.log10()
function to calculate the logarithm with base 10 of exceptional values.