Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Character Encodings  ›  Lesson

ASCII — 128 Characters, 7 Bits

ASCII 12 minASCII assigns the numbers 0 to 127 to English letters, digits, punctuation and control characters, so each fits in 7 bits.

ASCII — 128 Characters, 7 Bits

When you press the key A, the computer does not store a picture of the letter. It stores a number, and every program on the machine agrees which number means A. The first widely adopted agreement, from the 1960s, is ASCII, and it still sits underneath almost all text today.

The rule

ASCII gives 128 characters the numbers 0 to 127: seven bits each.

ASCII (American Standard Code for Information Interchange) covers:

  • 0–31 and 127: invisible control characters, such as newline (10), carriage return (13) and tab (9).
  • 32: the space.
  • 48–57: the digits 0–9.
  • 65–90: capitals A–Z.
  • 97–122: lowercase a–z.
  • The gaps hold punctuation and symbols, like ! (33) and @ (64).

Since 127 is the biggest code, 7 bits are enough; in practice each character is stored in a full byte with the top bit 0.

Notice the character '7' is not the number 7. It is code 55. Text that looks like a number must be converted before you can do arithmetic with it.

ASCII has no é, no ñ, no ₹ and nothing from Hindi, Chinese or Arabic. That limit is why Unicode exists, which is the next lesson.

The shortcut

Memorise three anchors, '0' = 48, 'A' = 65, 'a' = 97, and count from them. Two patterns do the rest: lowercase = uppercase + 32, and digit value = code − 48.

Working out codes without a tableStep 1 of 4
  1. A capital

    'G' is 6 letters after 'A': 65 + 6 = 71.

The 32 gap is no accident: 32 is a single bit (2⁵), so switching case just flips that one bit.

Drills

Answer fast — trust the rule.

quick drill

What is the ASCII code of 'C'?

quick drill

What is the ASCII code of 'd'?

quick drill

The character '7' has which ASCII code?

quick drill

Why can't the word 'café' be stored in plain ASCII?

Remember

  • ASCII: 128 characters, codes 0–127, seven bits.
  • Anchors: '0' = 48, 'A' = 65, 'a' = 97; lowercase = uppercase + 32.
  • The trap: the character '7' is code 55, not the number 7.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainReading the ASCII table

Using the anchors 'A' = 65, 'a' = 97 and '0' = 48, work out the codes for 'E', 'e' and '9'. Then explain why the gap of 32 between cases is handy, and why ASCII alone cannot store a word like 'café'.