Open thegedge opened 7 years ago
I'm completely 👍 for representing as rational internally. Helps us avoid precision loss. And is much more in spirit with the lazy conversion. Do the changes/math just in time.
And is much more in spirit with the lazy conversion. Do the changes/math just in time.
Could you expand on what you mean by "lazy" here? Do you mean we'd store given values and only convert to Rational
when first necessary?
The other way around. We store all factors/conversions in rational, and only convert to BigDecimal
or whatever when terminal.
I'm removing the 2.0 milestone. Doing this is backwards compatible in the sense that no contract has been established about exactly what we return here. Our README calls out that it could be either, so people will (hopefully) be writing code that can work with both.
There's no loss in operating with either, but there are pros and cons we need to weight against each other:
Representation
Rational
has the benefit of describing infinitely repeating rationals exactly (e.g., 1/3, 4/7), but cannot represent infinity.String parsing
Rational
andBigDecimal
have different profiles based on the type of string being parsed.Rational
is a little faster for integral values, but much slower for fractional values.Integral
Non-integral
Arithmetic
Rational
has much better performance for arithmetic.