find the base 10 logarithm of a number in swift

To find the base 10 logarithm of a number in Swift, you can use the built-in log10() function from the Foundation library. Here's an example of how to use it:

main.swift
import Foundation

let x = 100.0 // the number to find the logarithm of
let result = log10(x) // result will be 2, since log10(100) = 2
136 chars
5 lines

The log10() function takes in a single parameter, the number to find the logarithm of, and returns the base 10 logarithm of that number.

gistlibby LogSnag