There are many effective Rational NUmber implementations but one that has been proposed many times and can even handle some irrationals quite well is Continued Fractions.
Quote from Continued Fractions by Darren C. Collins:
Theorem 5-1. - The continued fraction expression of a real number is finite if and only if the real number is rational.
Quote fromMathworld - Periodic Continued Fractions
... a continued fraction is periodic iff it is a root of a quadratic polynomial.
i.e. all roots can be expressed as periodic continued fractions.
There is also an Exact Continued Fraction for π