Comparing and rewriting fractions