Hullaballoonatic
07/12/2020, 6:56 PMNumber
so limited? why doesn't it look something like this, at the very least?
interface Number<N: Number<N> : Comparable<N> {
operator fun plus(other: N): N
operator fun minus(other: N): N
operator fun times(other: N): N
operator fun div(other: N): N
operator fun unaryMinus(): N
val minValue: N
val maxValue: N
fun inverse(): N
fun toDouble(): Double
fun toFloat(): Float
fun toLong(): Long
fun toInt(): Int
fun toChar(): Char
fun toShort(): Short
fun toByte(): Byte
}
am i wrong in thinking all subclasses of Number implement those operators anyways?Dominaezzz
07/12/2020, 7:07 PMNumber
class. Not much can be done if 100% interop is desired.Dominaezzz
07/12/2020, 7:08 PMHullaballoonatic
07/12/2020, 7:26 PMNumber
really is, simply, to have functions to convert them to operable number types?Dominaezzz
07/12/2020, 7:31 PMAdam Juraszek
07/13/2020, 11:39 AMComplex
number is not comparable in mathematical sense and so it does not have minValue and maxValue.Zach Klippenstein (he/him) [MOD]
07/13/2020, 2:21 PMNumber
would not be an interface but something like a typeclass (KEEP-87), so that it could be used with all the existing numerical types. I bet #C5UPMM0A0 already has something like this 😂