- 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
| Code | Meaning | Notes |
|---|---|---|
| BCD | Binary Coded Decimal | Each decimal digit is written as its own 4-bit group |
| ASCII | American Standard Code for Information Interchange | Standard 7-bit code with 128 characters; an extended 8-bit version has 256 |
| EBCDIC | Extended Binary Coded Decimal Interchange Code | An 8-bit code used on some older mainframes |
| Unicode | Universal character set | Covers 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.
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. How many different patterns can 6 bits make?
- 64
- 6
- 32
- 128
Show answer
Answer: A. n bits give 2^n patterns: 2^6 = 64.
-
2. Write decimal 63 in BCD.
- 0011 1111
- 0110 0011
- 0011 0110
- 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. In ASCII, capital A is 65. What is capital E?
- 68
- 70
- 69
- 101
Show answer
Answer: C. E is four letters after A: 65 + 4 = 69. (101 is small e.)
-
4. What is the minimum number of bits needed to give a different code to each of 40 items?
- 5
- 7
- 40
- 6
Show answer
Answer: D. 2^5 = 32 is too few; 2^6 = 64 is enough, so 6 bits.
-
5. Which code covers the letters of most of the world's languages, including Indian scripts?
- Unicode
- 7-bit ASCII
- BCD
- EBCDIC
Show answer
Answer: A. Unicode is the universal character set. 7-bit ASCII has only 128 characters and BCD codes decimal digits.
Sign in to keep track of the lessons you finish.