Hacker News new | ask | show | jobs
by susam 2528 days ago
That's right. In fact, the latter would be just as easy as 1) subtract 10% 2) double 3) and add 32, i.e., the exact conversion formula again.

In other words, (c - c/10) * 2 + 32 = 2c - 2c/10 + 32 = 9c/5 + 32.

The only difference between the refined approximation and your approximation is 31 vs. 32 in the last step. The rationale for choosing 31 is explained in the "Analysis" section of the blog post. To summarize, when we subtract 10% in the approximation method, we do not perform an exact division. Instead, we perform a floor division (discard the fractional part) for easier mental calculation. The floor division introduces an error that lies in the interval [0, 2). If we subtract 1 from the result, then the error lies in the interval [-1, 1). Therefore, in order to prevent the magnitude of error from exceeding 1 °F, we add 31 instead of 32 in the last step.

Also, I find subtracting 10% of smaller number from itself slightly easier than doing so with a larger number. That's why the subtraction step comes before the doubling step.

1 comments

Ahh fair enough. I should have spent more time understanding your rationale. I'll edit my original comment to reflect that.