Scala Tutorial Scala References

Scala - Math E Field



The Scala Math E field is used to return the value of e to the available precision. It returns the value of e as 2.718281828459045.

Syntax

@inline final val E = java.lang.Math.E

Parameters

No parameter is required.

Return Value

Returns the value of e to the available precision.

Example:

In the example below, E constant is used to return the value of e to the available precision.

import scala.math._

object MainObject {
  def main(args: Array[String]) {
    System.out.println(s"E = ${E}");   
    System.out.println(s"log(E) = ${log(E)}");
    System.out.println(s"log10(E) = ${log10(E)}");      
  }
}

The output of the above code will be:

E = 2.718281828459045
log(E) = 1.0
log10(E) = 0.4342944819032518

❮ Scala Math Methods

5