Completed the conversion routine (general formula, no edge cases)