Introduction to Number Systems
A number system is a way to represent and express numbers. Different number systems are used in computing to represent data in various formats. The commonly used number systems are:
- Binary (Base-2): Uses two symbols: 0 and 1.
- Octal (Base-8): Uses eight symbols: 0 to 7.
- Decimal (Base-10): Uses ten symbols: 0 to 9 (the most familiar system).
- Hexadecimal (Base-16): Uses sixteen symbols: 0 to 9 and A to F.
Binary, Octal, and Hexadecimal Number Systems
Binary: The binary system uses two digits, 0 and 1, and is the foundation of all digital computing systems. Each binary digit is known as a bit.
Octal: The octal system uses eight digits (0 to 7) and is often used as a shorthand for binary numbers, grouping three binary bits into one octal digit.
Hexadecimal: The hexadecimal system uses sixteen symbols (0 to 9 and A to F). It is frequently used in programming to represent large binary numbers in a more compact form, with each hexadecimal digit representing four binary bits.
Conversion Between Number Bases
Converting numbers between bases is a common operation in computing. Below are examples of conversions with steps:
Binary to Decimal
Example: Convert 1011
to decimal.
- Write the binary number and assign powers of 2 to each bit from right to left:
2³, 2², 2¹, 2⁰
. - Multiply each bit by its corresponding power of 2:
1×2³ + 0×2² + 1×2¹ + 1×2⁰
. - Add the results:
8 + 0 + 2 + 1 = 11
. - Final Answer:
11
.
Decimal to Binary
Example: Convert 29
to binary.
- Divide the decimal number by 2 and write down the remainder.
- Continue dividing the quotient by 2 until the quotient is 0.
- Write the remainders in reverse order:
29 ÷ 2 = 14 R1, 14 ÷ 2 = 7 R0, 7 ÷ 2 = 3 R1, 3 ÷ 2 = 1 R1, 1 ÷ 2 = 0 R1
. - Final Answer:
11101
.
Binary to Octal
Example: Convert 101110
to octal.
- Group the binary digits into sets of three from right to left:
101 110
. - Convert each group to its decimal equivalent:
101 = 5
,110 = 6
. - Combine the results:
56
. - Final Answer:
56
.
Binary to Hexadecimal
Example: Convert 11011110
to hexadecimal.
- Group the binary digits into sets of four from right to left:
1101 1110
. - Convert each group to its decimal equivalent:
1101 = D
,1110 = E
. - Combine the results:
DE
. - Final Answer:
DE
.
Arithmetic Operations on Binary Numbers
Binary arithmetic is similar to decimal arithmetic but uses only two digits (0 and 1). Common operations include:
- Addition: Binary addition follows these rules:
- 0 + 0 = 0
- 0 + 1 = 1
- 1 + 0 = 1
- 1 + 1 = 10 (carry 1)
- Subtraction: Uses the concept of borrowing, similar to decimal subtraction.
- Multiplication: Binary multiplication follows these rules:
- 0 × 0 = 0
- 0 × 1 = 0
- 1 × 0 = 0
- 1 × 1 = 1
- Division: Follows the same logic as decimal division.
Example Questions
- Perform the binary addition of 1011 and 1101.
- Perform the binary subtraction of 10101 from 11110.
- Perform the binary multiplication of 110 and 101.
Alphanumeric Codes
Alphanumeric codes are used to represent characters and symbols in binary form. Commonly used codes include:
Code | Full Form | Description |
---|---|---|
BCD | Binary-Coded Decimal | Represents decimal numbers in binary form (e.g., 9 = 1001). |
EBCDIC | Extended Binary Coded Decimal Interchange Code | Used in IBM mainframes to represent alphanumeric data. |
ASCII | American Standard Code for Information Interchange | Represents characters in 7-bit binary format (e.g., A = 65 = 1000001). |
Unicode | Universal Code | A universal standard that encodes characters for all writing systems (e.g., UTF-8, UTF-16). |
Example Questions
- Convert the ASCII character A to its binary representation.
- Explain the difference between BCD and EBCDIC with examples.
- What is the Unicode representation of the character ₹?
Conclusion
Number systems and alphanumeric codes form the basis of digital computing. Understanding how to work with different number bases, convert between them, and perform arithmetic operations is essential for anyone working with computers or programming.
Practice Questions
- Convert the binary number
101101
to decimal, octal, and hexadecimal. - Perform the binary addition of
1011
and1101
. - Explain the difference between ASCII and Unicode with examples.
- Write a program to convert a decimal number to binary and hexadecimal in C.
- Explain how the EBCDIC code differs from ASCII with a focus on their usage.