How to memorize the ASCII table

Before discussing how you could memorize a table of ASCII characters and numeric values, I should say a little about why you might do so.

One reason is simply for the challenge. It’s more doable than it may sound.

It’s also useful information, though it’s debatable whether it’s worth memorizing. YMMV. There was a time early in my career when I spent a lot of time staring at a hex editor, and it definitely would have been useful to know then. I still need to look up ASCII values occasionally, though not as often.

ASCII table at the command line: ascii -d

One step in the process of memorizing the ASCII table is to associate an image with each ASCII character. This is useful by itself without learning the ASCII values of the characters. You could memorize strong passwords, for example, by linking together the images associated with each character.

I’ll only consider printable characters in this post.

ASCII landmarks

It’s very handy to know that the ASCII code for 0 is 48 and that the digits codes are in order. So the ASCII code for the digit d is d+48.

Wouldn’t it have been easier if the digits started at a location ending in zero? They do, in hexadecimal: digits start at 0x30.

Similarly, capital letters start at 65 (or 0x41). So the nth capital letter starts at n+64 (or n+0x40).

Lower case letters start at 97 (0x61), and so the nth lower case letter starts at n+96 (or n+0x60).

Incidentally, you’ll sometimes see software that sorts capital letters before lower case letters. The software is probably simply sorting by ASCII value.

In short, if you know the ASCII values of 0, A, and a then you can calculate the values of all digits and letters.

Memory pegs

You can create images for each ASCII character based on three things you may already know, and which are worth learning if you don’t.


One is the NATO phonetic alphabet: Alpha, Bravo, Charlie, Delta, …. If you know the NATO alphabet then you already have an image for each letter.

If you want to memorize a strong password, something like u\#mC_cNJ$o, then you need to distinguish upper and lower case letters. One way to do this would be to memorize two variations on each NATO word, one large and one small. For example, you might split the word Charlie into Charlie Chaplin for capital C and Charlie Brown for lower case c. For another, you might split golf into golf cart for G and golf ball for g.


The most common way to memorize digits is to encode them as words using the Major system. Zero is associated with the S sound, one is associated with the T sound, two is associated with the N sound, etc. See the preceding link for details.

You should come up with your own pegs that work for you, but here’s an example where each peg is a spice.

  1. cilantro
  2. turmeric
  3. nutmeg
  4. mustard
  5. rosemary
  6. lemon
  7. chili powder
  8. cayenne pepper
  9. vanilla
  10. peppermint.

Your pegs don’t need to be related. You could, for example, associate T with a T-bone steak, 7 with a catapult, and 9 with a protractor. But I thought it would be fun to create a list based on spices. Maybe the association with various tastes would make your mnemonics more memorable.


As with letters and digits, we can appeal to prior art to come up with images. Hacker slang associates a word with each symbol: bang for !, rabbit ears for “, splat for *, etc.

You might start with hacker slang and modify it to suit your taste.

Code values

Using the landmarks mentioned above, you could calculate the ASCII codes for any letter or digit. But if you want to associate letters and digits with their ASCII values more quickly, you need to directly associate each symbol directly with its value. Even if you don’t do this with letters and digits, you have to do it with other symbols because there’s no way to calculate the ASCII value of * or %, for example.

The most common technique for memorizing a numbered list is to memorize a set of pegs for each digit, then associate each list item with its number.

Creating and memorizing pegs for the numbers 1 through 128 is a lot of work, but it’s reusable. If you go to the effort, you can use it for memorizing a lot more than the ASCII table. For example, you could use it to memorize chemical elements.

If your peg for 42 is rain, you can imagine water balloons raining down and splattering on your driveway. That links the number 42 with the symbol * whose hacker slang is splat.

For another example, 94 is the ASCII value of caret (^), sometimes called carrot in hacker slang. You could a bear (94) standing up and eating a carrot like Bugs Bunny.

Update: What if you’d like to memorize Unicode?

More posts on mnemonics

Voiced and unvoiced consonants and digits

The latest episode of The History of English Podcast discusses the history of pronunciation changes in the Elizabethan period. The episode has a lot to say about the connections between voiced and unvoiced pairs of consonants, and the circumstances under which a consonant might change from voiced to unvoiced and vice versa.

The major mnemonic system encodes digits as consonant sounds in order to make words out of numbers. The system works in terms of sounds, not spellings, and so some of the symbols below are not English letters but rather IPA symbols [1]. More on the system here.

0: S Z, 1: T D ð θ, 2: N ŋ, 3: M, 4: R, 5: L, 6: ʤ ʧ ʃ ʒ, 7: K G, 8: F V, 9: P B

If you’re not familiar with the concept of voiced and unvoiced vocal sounds it may seem arbitrary that, for example, the F and V sounds both decode to 8, or that the S and SH sounds map to different numbers, 0 and 6 respectively.

The allocation of sounds may seem inefficient at first.Some numbers get more sounds than others because some sounds belong to clusters of related sounds and some do not. For example, there’s no such thing as an unvoiced L sound, so 5 gets L and no other sound. But 8 gets P and B because these are unvoiced and voiced variations of the same sound.

The allocation is more uniform than it seems at first when you count consonant groups rather than individual consonant sounds.


[1] Here are the IPA symbols above that do not correspond to English letters.

| IPA | Example |
| ð   | THis    |
| θ   | THistle |
| ŋ   | siNG    |
| ʤ   | Jar     |
| ʧ   | CHurCH  |
| ʃ   | SHoe    |
| ʒ   | corsaGe |

For more on IPA, see the Wikipedia IPA help page.

100 digits worth memorizing

I was thinking today about how people memorize many digits of π, and how it would be much more practical to memorize a moderate amount of numbers to low precision.

So suppose instead of memorizing 100 digits of π, you memorized 100 digits of other numbers. What might those numbers be? I decided to take a shot at it. I exclude things that are common knowledge, like multiplication tables up to 12 and familiar constants like the number of hours in a day.

There’s some ambiguity over what constitutes a digit. For example, if you say the speed of light is 300,000 km/s, is that one digit? Five digits? My first thought was to count it as one digit, but then what about Avagadro’s number 6×1023? I decided to write numbers in scientific notation, so the speed of light is 2 digits (3e5 km/s) and Avagadro’s number is 3 digits (6e23).

Here are 40 numbers worth remembering, with a total of 100 digits.

Powers of 2

23 = 8
24 = 16
25 = 32
26 = 64
27 = 128
28 = 256
29 = 512
210 = 1024


13² = 169
14² = 196
15² = 225


P(|Z| < 1) ≈ 0.68
P(|Z| < 2) ≈ 0.95

Here Z is a standard normal random variable.


Middle C ≈ 262 Hz
27/12 ≈ 1.5

The second fact says that seven half steps equals one (Pythagorean) fifth.

Mathematical constants

π ≈ 3.14
√2 ≈ 1.414
1/√2 ≈ 0.707
φ ≈ 1.618
loge 10 ≈ 2.3
log10 e ≈ 0.4343
γ ≈ 0.577
e ≈ 2.718

Here φ is the golden ratio and γ is the Euler-Mascheroni constant.

I included √2 and 1/√2 because both come up so often.

Similarly, loge 10 and log10 e are reciprocals, but it’s convenient to know both.

The number of significant figures above is intentionally inconsistent. It’s at least as easy, and maybe easier, to remember √2 as 1.414 than as 1.41. Similarly, if you’re going to memorize that log10 e  is 0.43, you might as well memorize 0.4343. Buy two get two free.

Each constant is truncated before a digit less than 5, so all the figures are correct and correctly rounded. For φ and loge 10 the next digit is a zero, so you get an implicit extra digit of precision.

The requirement that truncation = rounding means that you have to truncate e at either 2.7 or 2.718. If you’re going to memorize the latter, you could memorize six more digits with little extra effort since these digits are repetitive:

e = 2.7 1828 1828

Measurements and unit conversion

c = 3e8 m/s
g = 9.8 m/s²
NA = 6e23
Earth circumference = 4e7m
1 AU = 1.5e8 km
1 inch = 2.54 cm

Floating point

Maximum double = 1.8e308
Epsilon = 2e-16

These numbers could change from system to system, but they rarely do. See Anatomy of a floating point number.


1 dB = 100.1 = 1.25
2 dB = 100.2 = 1.6
3 dB = 100.3 = 2
4 dB = 100.4 = 2.5
5 dB = 100.5 = 3.2
6 dB = 100.6 = 4
7 dB = 100.7 = 5
8 dB = 100.8 = 6.3
9 db = 100.9 = 8

These numbers are handy, even if you don’t work with decibels per se.

Update: The next post points out a remarkable pattern between the first and last sets of numbers in this post.

Related posts

Major memory system telephone keypad

This weekend I had to enter an alphabetic passcode on a numeric keypad. The keypad used the same letter-to-digit convention as a phone, but the letters were not printed on the keypad. That made me think about how much better the Major system is.

I wondered what phone keypads would look like if they used the Major memory system, and so I made the image below.

0: S Z, 1: T D ð θ, 2: N ŋ, 3: M, 4: R, 5: L, 6: ʤ ʧ ʃ ʒ, 7: K G, 8: F V, 9: P B

The Major memory system is a way of encoding numbers as words to make them easier to memorize. The system associates a consonant sound with each digit; you’re free to insert any vowels you like. For example, if you wanted to memorize 745, you might encode it as gorilla.

Note that gorilla decodes to 745 and not 7455 because the word has only one L sound, even though it is spelled with two Ls.

One nice feature of the Major system is that if you multiply a number by 10, you can pluralize its mnemonic. For example, a possible mnemonic for 7450 is gorillas.

The Major system emphasizes sounds because humans remember sounds more easily than symbols. If you have a photographic memory for symbols, just memorize the digits and don’t bother with any mnemonic system.

Some of the sounds associated with digits are not represented by a single letter in English and so the keypad above contains a few IPA (International Phonetic Alphabet) symbols. The number 1 is encoded by any of the sounds “t”, “d”, or “th.” The IPA symbol θ represents the th sound in think and the ð represents the th sound in this. The symbol ŋ as a possible encoding for 2 represents the ng sound in sing. And the number 6 can be encoded as one of several similar sounds: ch, sh, soft g, or soft z.

The conventional phone keypad looks simpler: 2 = A, B, or C, 3 = D, E, or F, etc. It’s the kind of thing James Scott would call “legible,” something that looks simple on paper and warms a bureaucrat’s heart, but doesn’t necessarily work well in practice. The sounds associated with the letters for a given digit have nothing in common, so a number can be represented by dissimilar sounds, and similar sounds do not represent the same number.

Encoding telephone numbers as words is rarely possible using the conventional keypad letters. Phone numbers that do correspond to memorable words are highly valued. Every letter has to correspond to a digit, and it matters how the word is spelled.

The Major system is much more flexible since you’re free to supply vowels as you wish, and you can choose from a wide variety of words that spell a single consonant sound in different ways.

Related posts

Memorizing numbers and enumerating possibilities

This post will illustrate two things: how to memorize numbers, and how to enumerate products of sets in Python.

Major system

There’s a way of memorizing numbers by converting digits to consonant sounds, then adding vowels to make memorable words. It’s called the “major” mnemonic system, though it’s not certain where the system or the name came from.

I learned the major system as a child, but never used it. I thought about it more recently when I ran across the article Harry Potter and the Mnemonic Major System by Kris Fris.

Here is the encoding system in the form of a Python dictionary, using IPA symbols for the consonant sounds.

    digit_encodings = {
        0: ['s', 'z'],
        1: ['t', 'd', 'ð', 'θ'],
        2: ['n', 'ŋ'],
        3: ['m'],
        4: ['r'],
        5: ['l'],
        6: ['ʤ', 'ʧ', 'ʃ', 'ʒ'],
        7: ['k', 'g'],
        8: ['f', 'v'],
        9: ['p', 'b']

The method is based on consonant sounds, not spelling. For example, the word “circle” would be a possible encoding of the number 0475. Note that the soft ‘c’ in circle encodes a 0 and the hard ‘c’ encodes a 7.

It’s curious that some digits have only one associated consonant sound, while others have up to four. The method was not originally designed for English, at least not modern English, and there may be some historical vestiges of other languages in the system. Even so, the sounds are fairly evenly spread out phonetically. It may not be optimal for English speakers, but some care went into designing it.

For more on the major system, see its Wikipedia page.

Enumerating set products

There are multiple consonant sound choices for a given digit, and so it would be natural to enumerate the possibilities when searching for a suitable encoding of a number.

If you only ever worked with two digit numbers, you could use a pair of for loops. But then if you wanted to work with three digit numbers, you’d need three nested for loops. For a fixed number of digits, this is messy, and for a variable number of digits it’s unworkable.

The function product from itertools gives an elegant solution. Pass in any number of iterable objects, and it will enumerate their Cartesian product.

    from itertools import product

    def enumerate_ipa(number):
        encodings = [digit_encodings[int(d)] for d in str(number)]
        for p in product(*encodings):

In the code above, encodings is a list of lists of phonetic symbols. Unfortunately product takes lists as its argument, not a list of lists. The * operator takes care of unpacking encodings into the form product wants.


Suppose you wanted to use the major system to memorize

1/π = .31830988

I’m not recommending that you memorize this number, or that you use the major system if you do want to memorize it, but let’s suppose that’s what you’d like to do.

You could break the digits into groups however you like, but here’s what you get if you divide them into 318, 309, and 88.

The digits in 318 could be encoded as mtf, mtv, mdf, mdv, mðf, mðv, mθf, or mθv.

The digits in 309 could be encoded as msp, msb, mzp, or mzb.

The digits in 88 could be encoded as ff, fv, vf, or vv.

So one possibility would be to encode 31830988 as “midwife mishap fife.” You could think of a pie that got turned upside down. It was the midwife’s mishap, knocked over while she was playing a fife.

Notice that the “w” sound in “midwife” doesn’t encode anything, nor does the “h” sound in “mishap.”

Related posts

Number of feet in a mile

Here are a couple amusing things I’ve run across recently regarding the number of feet in a mile. Both are frivolous, but also have a more serious side.


First, you can use “five tomatoes” as a mnemonic for remembering that there are 5280 feet in a mile.

As I’ve argued earlier, systems of units that seem awkward now were designed according to different criteria. If you pointed out to a medieval Englishman that the number of feet in a mile is hard to remember, he might ask “Why would you want to convert feet into miles?”

Almost integers

The number of feet in a mile is very nearly

e^{\pi \sqrt{67}/3}

The exact value of the expression above is 5280.0000088… The difference between a mile and exp(π √67 / 3) feet is less than the length of an E. coli bacterium.

When people see examples like this, an expression that can’t be an integer and yet is eerily close to being an integer, some ask whether there’s a reason. Others think the question is meaningless. “The number equals whatever it equals, and it happens to be near an integer. So what?”

But there is some deeper math going on here. I touch on the reason in this post. 67 is a Heegner number, and so exp(π √67) is nearly an integer. That integer is 5280³ + 744 and so exp(π √67 / 3) ≈ 5280.

Lurking in the background is something called the j-function. It has something to do with why some expressions are very nearly integers. Incidentally, the number 744 mentioned above is the constant term in the Laurent expansion for the j-function.

Pi and The Raven

Michael Keith rewrote Edgar Allan Poe’s poem The Raven to turn it into a mnemonic for pi. Keith’s version follows the original quite well considering his severe constraints. The full poem has 18 stanzas. Here I include only the first and last. The full version can be found here.

* * *

Poe, E.
Near a Raven

Midnights so dreary, tired and weary,
Silently pondering volumes extolling all by-now obsolete lore,
During my rather long nap — the weirdest tap!
An ominous vibrating sound disturbing my chamber’s antedoor.
“This,” I whispered quietly, “I ignore.”

So he sitteth, observing always, perching ominously on these doorways.
Squatting on the stony bust so untroubled, O therefore.
Suffering stark raven’s conversings, I am so condemned, subserving,
To a nightmare cursed, containing miseries galore.
Thus henceforth, I’ll rise (from a darkness, a grave) — nevermore!

* * *

The number of letters in most words encodes a digit of pi. Words with 10 letters encode a zero. Words with more than 10 letters encode two consecutive digits of pi. The poem encodes the first 740 digits of pi.

Napier’s mnemonic

John Napier (1550–1617) discovered a way to reduce 10 equations in spherical trig down to 2 equations and to make them easier to remember.

Draw a right triangle on a sphere and label the sides a, b, and c where c is the hypotenuse. Let A be the angle opposite side a, B the angle opposite side b, and C the right angle opposite the hypotenuse c.

There are 10 equations relating the sides and angles of the triangle:

sin a = sin A sin c = tan b cot B
sin b = sin B sin c = tan a cot A
cos A = cos a sin B = tan b cot c
cos B = cos b sin A = tan a cot c
cos c = cot A cot B = cos a cos b

Here’s how Napier reduced these equations to a more memorable form. Arrange the parts of the triangle in a circle as below.

Then Napier has two rules:

  1. The sine of a part is equal to the product of the tangents of the two adjacent parts.
  2. The sine of a part is equal to the product of the cosines of the two opposite parts.

For example, if we start with a, the first rule says sin a = cot B tan b. (The tangent of the complementary angle to B is the cotangent of B.) Similarly, the second rule says that sin a = sin c sin A. (The cosine of the complementary angle is just the sine.)

For a more algebraic take on Napier’s rules, write the parts of the triangle as

(p1, p2, p3, p4, p5) = (a , b, co-A, co-c, co-B).

Then the equations above can be reduced to

sin pi = tan pi-1 tan pi+1 = cos pi+2 cos pi+3

where the addition and subtraction in the subscripts is carried out mod 5. This is just using subscripts to describe the adjacent and opposite parts in Napier’s diagram.

Source: Heavenly Mathematics

Related posts