Skip to content

Instantly share code, notes, and snippets.

@danslapman
Last active February 21, 2018 14:30
Show Gist options
  • Save danslapman/10429c00762c5d92388c5cc95fa094d1 to your computer and use it in GitHub Desktop.
Save danslapman/10429c00762c5d92388c5cc95fa094d1 to your computer and use it in GitHub Desktop.
Generic power operator
implicit class PowerOp[T <: AnyVal](val value: T) extends AnyVal {
import Numeric.Implicits._
import scala.{math => scmath}
@inline def **(power: T)(implicit numeric: Numeric[T]): Double =
scmath.pow(value.toDouble(), power.toDouble())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment