jump to navigation

A quadrillion dollars in debt July 15, 2009

Posted by Peter Hornby in software, tech.

After an unconscionable period of quiet, the blog bursts into life with a post which will probably only be of interest to a small subset of my vast reader audience.

The BBC reported today that some poor guy in New Hampshire discovered that his bank had debited his account by $23 quadrillion dollars after he bought a packet of cigarettes at a local gas station.

The story concludes:

But no-one has yet explained to Mr Muszynski how such a astonishing error could have been made.

I’m here to help.

The amount quoted in the story is $23,148,855,308,184,500.00

Type eight space characters into a text editor.  It’ll look like  ”        ” on screen (minus the quotes, of course).  What has the computer stored in memory?  If your text editor uses the ASCII character-encoding scheme, you’ll get 3264 bits which look like this when represented hexadecimally – “2020202020202020”.  Each “20” is the ASCII representation of a space character.

Here’s where it gets interesting.  Suppose you tell the computer that this memory location doesn’t contain a string, but a decimal value, what do you get?  The answer is 2314885530818453536.  I’m not sure how the bug manifested itself, but it seems likely that some memory location which was supposed to contain the number of cents in the debit amount was actually overwritten with a text string which was all, or almost all, spaces.

Oh well, geek credentials established.  Now back to hummingbirds and choral music.

Updated: Peter points out in comments that eight spaces take 64 bits, not 32.  Indeed they do (slaps forehead in annoyance).  He also points out that “2020202020201250” converts exactly to the correct decimal value, and wonders whether the pack of  cigarettes cost $12.50.  Maybe.  Thanks for the notes, Peter.



1. Peter - July 15, 2009

Minor point, those eight spaces would be stored in 64 bits, not 32, Which I’m sure is what you meant :)

Also a hex value of “2020202020201250” gives the precise result in decimal. I wonder whether $12.50 was the cost of the goods.

2. doesn't matter - July 15, 2009

I’m quite ok with you deleting my comment, but at least you might fix the errors in the text.
1 space = 8 bits.
8 spaces = 64 bits

3. Peter Hornby - July 15, 2009

Peter – sorry for the delay in approving your comment. I had to leave for a while. No slight intended, and your comment is valuable and appreciated.

4. Another expensive bug | verb. sap. - June 21, 2017

[…] wrote about the strange case of the gentleman from New Hampshire whose bank debited his account by 23 quadrillion dollars after he bought a pack of cigarettes at a gas station.   This still looks like a fairly […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: