The pow()
function calculates the value of the
Figure 1 shows the mathematical representation of the pow()
function.
The following module is required for this function:
import scala.math._
import scala.math._object Main extends App {//positive: baseNumber positive: exponentprintln(s"The value of pow(2,3) = ${pow(2,3)}");//positive: baseNumber negative: exponentprintln(s"The value of pow(0.25,-2) = ${pow(0.25,-2)}");//negative: baseNumber positive: exponentprintln(s"The value of pow(-10,2) = ${pow(-10,2)}");//negative: baseNumber negative: exponentprintln(s"The value of pow(-0.5,-1) = ${pow(-0.5,-1)}");//error ouputprintln(s"The value of pow(Double.PositiveInfinity,Double.PositiveInfinity) = ${pow(Double.PositiveInfinity,Double.PositiveInfinity)}");println(s"The value of pow(Double.NegativeInfinity,Double.NegativeInfinity) = ${pow(Double.NegativeInfinity,Double.NegativeInfinity)}");println(s"The value of pow(Double.NaN,Double.NaN) = ${pow(Double.NaN,Double.NaN)}");}