Converting rational numbers between different bases and representations