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.
Figure 1 shows the mathematical representation of the exp() function.
The following module is required for this function.
import scala.math._
def exp(x: Double): Double
This function requires a number as a parameter.
exp() returns the mathematical e raised to the power of the specific number sent as a parameter.
If the parameter value is
PositiveInfinity, then it returns positive infinity.
If the parameter value is
NegativeInfinity, then it returns zero.
If the parameter value is
NaN, then it returnsNaN.
import scala.math._object Main extends App {//positive numberprintln(s"The value of exp(10) = ${exp(10)}");//negative numberprintln(s"The value of exp(-2) = ${exp(-2)}");//zero numberprintln(s"The value of exp(0) = ${exp(0)}");//error outputsprintln(s"The value of exp(Double.PositiveInfinity) = ${exp(Double.PositiveInfinity)}");println(s"The value of exp(Double.NegativeInfinity) = ${exp(Double.NegativeInfinity)}");println(s"The value of exp(Double.NaN) = ${exp(Double.NaN)}");}