Question: In a language that supports operator overloading, build support for rational numbers. Each number should be represented internally as a (numerator, denominator) pair in simplest
In a language that supports operator overloading, build support for rational numbers. Each number should be represented internally as a (numerator, denominator) pair in simplest form, with a positive denominator. Your code should support unary negation and the four standard arithmetic operators. For extra credit, create a conversion routine that accepts two floatingpoint parameters—a value and a error bound—and returns the simplest (smallest denominator) rational number within the given error bound of the given value.
Step by Step Solution
3.36 Rating (174 Votes )
There are 3 Steps involved in it
Heres a solution in C Simple class for rational numbers in C Fractions are always kept in r... View full answer
Get step-by-step solutions from verified subject matter experts
