Fixed getCommonNumerator overflow
Improved comparison algorithm