This performs arithmetic operations using rational numbers.
Rational numbers are those numbers that can be represented as the ratio between two integer numbers. Any real number with a finite number decimal digits or that repeats a sequence of digits can be represented as a rational number.
This class can add, subtract, multiply, and divide rational numbers.
The results of the operations are also rational numbers, simplified to eliminate any common factors of the the numerator and denominator. This way the arithmetic operations are performed without loss of precision, a common failing of floating point arithemetic. |