Refactor the code a bit and make binary-decimal conversion correctly rounded for all exponent values.