If I have code like 5 * 5.0
the result gets converted to the most accurate type, Double
.
But this doesn't seem to work with code like
case class Value[T : Numeric](value: T) {
type This = Value[T]
def +(m: This) = Value[T](implicitly[Numeric[T]].plus(value, m.value))
...
}
implicit def numToValue[T : Numeric](v: T) = Value[T](v)
Is there a way to make things like someIntValue + double
work, where someIntValue
is Value[Int]
and double
is Double
?
PS: Sorry for the far less-than-perfect title. I'm thankful for suggestions for better wording ...