Open matterhorn103 opened 1 month ago
Notably, rounding would require a different implementation.
When used on a Fraction
, the number seems to be rounded in the normal way for floats, but expressed as a decimal fraction e.g.
Meanwhile, complex
doesn't even define __round__()
. So would we make rounding work for complex quantities via another method, or would we let it return the same error for consistency with Python's implementation?
Since complex
is kind of annoying, can't be cast to anything else, and has different methods to Fraction and Decimal, for implementation of complex numbers it might be worth considering adding an imaginary decimal component to Quantity.
This would require reimplementation of the whole logic of complex numbers though – presumably a pointless reinvention of the wheel that is likely to lose a lot of optimization benefits of complex
.
NaN
is already permitted as it is part ofDecimal
just likeinf
and-0
, but important to check thatQuantity
's methods don't run into issues due to assuming thatnumber
will always be realcomplex
orFraction
when used to create aQuantity
Quantity
(and ofUnit
) i.e. that not everything works with all types"1+2j"
"1/2"
as being complex and fractional respectively and pass them tocomplex()
orFraction()
as appropriate