Multiplying our way out of division
xania.org·9h
📐Interval Arithmetic
Preview
Report Post

Written by me, proof-read by an LLM. Details at end.

I occasionally give presentations to undergraduates, and one of my favourites is taking the students on a journey of optimising a “binary to decimal” routine1. There are a number of tricks, which I won’t go in to here, but the opening question I have is “how do you even turn a number into its ASCII representation?”

If you’ve never stopped to think about it, take a moment now to do so, it can be a fun problem.

The simple2 approach is to use number % 10 to get the rightmost digit (adding 48 to turn it into the ASCII number), then divide by ten, and keep going until the number is zero. This produces the digits backwards3, but you can reverse them afterwards, which I won’t show here. This rout…

Similar Posts

Loading similar posts...