Michael Maclean

Debug of the year

I saw this article on the BBC, where a man who bought a packet of cigarettes from a petrol station in the US ended up being charged $23,148,855,308,184,500 instead. Wow. I was a little curious as to how this could have happened, though the number didn’t look familar - I know roughly what 2^32, 2^32 / 2, 2^64, 2^64 / 2 look like, and this didn’t appear to be any of those. A swift Google though led me to Stack Overflow, which is a fantastic site. Therein lies a quite plausible explanation:

Add the cents to the number and you get 2314885530818450000, which in hexadecimal is 2020 2020 2020 1250. Do you see the pattern? The first six bytes has been overwritten by spaces (hex 20, dec 32).

Ingenious! I can imagine spending quite a while trying to come up with that…