sp0 wrote:
Is there a reason why to make mix numbers improper when adding?
Is there a reason to store a fraction as a whole number and a fractional
part? Doesn't it lead to a lot of unnecessary complications (like this
one) in your code?
It seems when subtracting and adding, adding a subtracting the whole
numbers and fraction parts should be sufficient? what'ch think
Adding or subtracting the fractional parts will be formally exactly the
same as adding or subtracting two improper fractions. All a mixed
representation does is add complexity.
I suggest you store rationals as numerator-denominator and produce
mixed-fraction representations only as required. Or let the user produce
them herself. She has access to the (coprime) numerator and denominator
and can calculate the quotient and remainder from them, right?
Regards,
Buster.