I am stuck with a problem. I am programming a fractions calculator (for an Assignment). So far it works great, the problem is I have to handle arithmetic overflow. I did some research an understand overflow now. But, I don't know how to handle it. The overflow is caused by the simple operations between nominator and denominator.
The example we are given is that the fraction operation: 999999/1000000 * 500000/999999 should give the answer 1/2. When my program goes to multiply 999999 * 500000 there is an overflow and the end result is inaccurate (I get -2 10204169/22761874).
The main objective is to produce correct results whenever the reduced number can be correctly represented without overflow.
Any help is greatly appreciated.