In Swift, the exp()
function returns the mathematical e raised to the power of a specific number. Here, Euler’s number e is the base of the natural logarithm.
The mathematical representation of the exp()
function is shown below:
Note: We need to import
Foundation
in our code to use theexp()
function. We can import it like this:import Foundation
.
// number should be float, double or real.exp(number)
This function requires a number
as a parameter.
This function returns the mathematical e raised to the power of number
sent as a parameter.
The code below shows the exp()
function in Swift:
import Swiftimport Foundation// Positive Integerprint ("The value of exp(4.0) : ", exp(4.0));//zeroprint ("The value of exp(0.0) : ", exp(0.0));// Negative Integerprint ("The value of exp(-25.0) : ", exp(-25.0));//Positive double valueprint ("The value of exp(4.4) : ", exp(4.4));//Negative double valueprint ("The value of exp(-4.5) : ", exp(-4.5));
Foundation
header required for the exp()
function.exp()
.exp()
.exp()
.exp()
.exp()
.