matterhorn103 / quanstants

Intuitive and unastonishing physical quantities, units, constants, and uncertainties in Python
MIT License
0 stars 0 forks source link

Allow fractions, complex numbers, NaN for a Quantity's number #36

Open matterhorn103 opened 1 month ago

matterhorn103 commented 1 month ago
matterhorn103 commented 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?

matterhorn103 commented 1 month ago

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.