While it's obvious that you're trying to simulate the results of floating point division, there's no need to shift the two mantissas to the right. The thing that needs to be done tho' is right shifting the lesser of the two fractions in order to equalise them. After equalising, if numerator <= denominator, repeatedly multiply it by 10 until it becomes just greater than the denominator, specifically:

And no need to store the result ofCode:1 / 5 frac1 = 1 (1.0 x 2^0 - binary) frac2 = 5 (1.01 x 2^2 - binary) frac1 >>= 2; // equalise the magnitudes of the two fractions while (frac1 < frac2) frac1 *= 10;FRAC1 / FRAC2in a float, as it can obtained thro' integer division and modulus.