An elegant way to convert quantities between different units