If you are willing to restrict your domain to rational numbers, a simple implementation of a Rational type is another good solution. Store the numerator and denominator and add a least-common-multiple implementation (for finding the common denominator) and you are off to the races!
If you are willing to restrict your domain to rational numbers, a simple implementation of a
Rational
type is another good solution. Store the numerator and denominator and add a least-common-multiple implementation (for finding the common denominator) and you are off to the races!Ohh, I didn't think about it, and yes, they are only rational numbers. Thank you Evan :D
I thought I had implemented
Rational
before, here is my quick implementation for this Stack Overflow question:Nice