Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (21 sloc) 892 Bytes
import scala.math._
scala.math.Pi // 3.141592653589793
scala.math.E // 2.718281828459045
// numerical operations, more at https://www.scala-lang.org/api/2.12.3/scala/math/index.html
scala.math.abs(-20) // 20
scala.math.pow(2, 3) // 8.0
scala.math.floor(2.945) // 2.0
scala.math.exp(1) // 2.718281828459045
scala.math.sqrt(16) // 4.0
// example
scala.math.sin(4 * math.Pi / 180) // 0.0697564737441253
// rounding values
scala.math.round(2.945) // 3
scala.math.round(2.495) // 2
// or
scala.math.rint(2.945 * 100) / 100 // 2.94
'''
Michael Sjoeberg
2018-11-06
https://github.com/michaelsjoeberg/scala-playground/blob/master/basic-syntax/math.scala
'''
You can’t perform that action at this time.