• Foundation
  • About 12 min
  • 5 practice questions

Codes: BCD, ASCII, Unicode and bit capacity

Explain how characters are represented in binary and how many values n bits can hold.

If something looks wrong, please tell us.

Computers store letters, symbols and even Hindi or Tamil text as numbers. A code is the agreed table that links characters to numbers.

How many values can n bits hold?

With n bits there are 2^n different patterns. 1 bit gives 2 values, 2 bits give 4, 3 bits give 8, 4 bits give 16, 8 bits give 256.

Character codes

Codes
CodeMeaningNotes
BCDBinary Coded DecimalEach decimal digit is written as its own 4-bit group
ASCIIAmerican Standard Code for Information InterchangeStandard 7-bit code with 128 characters; an extended 8-bit version has 256
EBCDICExtended Binary Coded Decimal Interchange CodeAn 8-bit code used on some older mainframes
UnicodeUniversal character setCovers letters of most of the world's languages, including Indian scripts

In ASCII, capital A is 65, B is 66 and so on; small a is 97. The digit 0 is 48.

Worked examples

Example 1. How many characters can a 7-bit code represent? 2^7 = 128.

Example 2. Write decimal 47 in BCD. Write each digit in 4 bits: 4 = 0100 and 7 = 0111, so 0100 0111.

Example 3. What is the ASCII value of C? A is 65, so C is 67.

Example 4. Minimum bits to represent 100 different items? 2^6 = 64 is too few and 2^7 = 128 is enough, so 7 bits.

n bits give 2^n patterns. ASCII A = 65, a = 97. BCD uses 4 bits per decimal digit.

— Remember

Key takeaways

  • Characters are stored as numbers using a code.
  • n bits hold 2^n patterns.
  • ASCII is 7-bit; Unicode covers many scripts.

Check your understanding

  1. 1. How many different patterns can 6 bits make?

    1. 64
    2. 6
    3. 32
    4. 128
    Show answer

    Answer: A. n bits give 2^n patterns: 2^6 = 64.

  2. 2. Write decimal 63 in BCD.

    1. 0011 1111
    2. 0110 0011
    3. 0011 0110
    4. 0110 0110
    Show answer

    Answer: B. Each decimal digit gets its own 4 bits: 6 = 0110 and 3 = 0011. (0011 1111 is 63 in pure binary.)

  3. 3. In ASCII, capital A is 65. What is capital E?

    1. 68
    2. 70
    3. 69
    4. 101
    Show answer

    Answer: C. E is four letters after A: 65 + 4 = 69. (101 is small e.)

  4. 4. What is the minimum number of bits needed to give a different code to each of 40 items?

    1. 5
    2. 7
    3. 40
    4. 6
    Show answer

    Answer: D. 2^5 = 32 is too few; 2^6 = 64 is enough, so 6 bits.

  5. 5. Which code covers the letters of most of the world's languages, including Indian scripts?

    1. Unicode
    2. 7-bit ASCII
    3. BCD
    4. EBCDIC
    Show answer

    Answer: A. Unicode is the universal character set. 7-bit ASCII has only 128 characters and BCD codes decimal digits.

Privacy · Terms · Refunds · Delivery