CLOVIS
02/05/2025, 9:15 PMNumber
doesn't enforce the presence of unaryMinus
. Is there a subtype for "`Number` instances that also have a unaryMinus
?"
I have a DSL which has a +=
operator, I thought I'd provide a -=
operator for convenience, but I would need to negate the value for thatSkaldebane
02/05/2025, 9:25 PMNumber
(nor do they have their own interface, surprisingly).CLOVIS
02/05/2025, 9:26 PMNumber
for complex numbers or other weird casesSkaldebane
02/05/2025, 9:27 PMNumber
types may be an option.Ruckus
02/05/2025, 9:28 PMNumber
doesn't enforce the presence of any operator, so I would whatever you did for the +=
operator is exactly the same as what you would do for the -=
operator, correct?Skaldebane
02/05/2025, 9:29 PMRuckus
02/05/2025, 9:30 PMNumber
for complex numbers...
I'm not sure that's such a useful argument, since the existing functions on Number
(e.g. toInt
) don't really make sense for complex numbers either.ephemient
02/06/2025, 12:46 AMit doesn't enforce the presence of anything except conversion to primitives.doesn't enforce the presence ofNumber
unaryMinus
AtomicInteger
is a Number
.
I think it's to allow you to create your own impl ofI don't agree. various parts of the Java only handle the specific built-in numeric types (e.g. Format), but there was no way to enforce sealed classes in Java originally, and that's carried into Kotlin for compatibility. it's not a useful class to extendfor complex numbers or other weird casesNumber