Computer Number Systems-BCA
A number system defines a way to represent numbers. Computers use different number systems for processing and representation. The most common systems are Binary, Decimal, Octal, and Hexadecimal.
1.
Binary Number System
- Base: 2
- Digits Used: 0, 1
- Example: 101121011_210112
- How it Works:
Each binary digit (bit) represents a power of 2. For example:
10112=(1×23)+(0×22)+(1×21)+(1×20)=11101011_2 = (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0) = 11_{10}10112=(1×23)+(0×22)+(1×21)+(1×20)=1110
Use:
Widely used in computers for internal data representation and processing.
2.
Decimal Number System
- Base: 10
- Digits Used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Example: 25610256_{10}25610
- How it Works:
Each digit represents a power of 10. For example:
25610=(2×102)+(5×101)+(6×100)256_{10} = (2 \times 10^2) + (5 \times 10^1) + (6 \times 10^0)25610=(2×102)+(5×101)+(6×100)
Use:
The most commonly used number system in daily life.
3.
Octal Number System
- Base: 8
- Digits Used: 0, 1, 2, 3, 4, 5, 6, 7
- Example: 1578157_81578
- How it Works:
Each digit represents a power of 8. For example:
1578=(1×82)+(5×81)+(7×80)=11110157_8 = (1 \times 8^2) + (5 \times 8^1) + (7 \times 8^0) = 111_{10}1578=(1×82)+(5×81)+(7×80)=11110
Use:
Used in computer systems for compact binary representation.
4.
Hexadecimal Number System
- Base: 16
- Digits Used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
- A=10A = 10A=10, B=11B = 11B=11,
C=12C = 12C=12, D=13D = 13D=13, E=14E = 14E=14, F=15F = 15F=15
- Example: 2F3162F3_{16}2F316
- How it Works:
Each digit represents a power of 16. For example:
2F316=(2×162)+(15×161)+(3×160)=755102F3_{16} = (2 \times 16^2) + (15 \times 16^1) + (3 \times 16^0) = 755_{10}2F316=(2×162)+(15×161)+(3×160)=75510
Use:
Widely used in programming, memory addressing, and color codes.
Comparison
of Number Systems
System |
Base |
Digits
Used |
Example |
Binary |
2 |
0, 1 |
101121011_210112 |
Decimal |
10 |
0–9 |
25610256_{10}25610 |
Octal |
8 |
0–7 |
1578157_81578 |
Hexadecimal |
16 |
0–9, A–F |
2F3162F3_{16}2F316 |
Conversions
Between Systems
- Binary to Decimal
Multiply each bit by 2n2^n2n and sum them.
Example: 11012=(1×23)+(1×22)+(0×21)+(1×20)=13101101_2 = (1 \times 2^3) + (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0) = 13_{10}11012=(1×23)+(1×22)+(0×21)+(1×20)=1310 - Decimal to Binary
Divide the decimal number by 2 and write the remainders in reverse.
Example: 1310=1101213_{10} = 1101_21310=11012 - Binary to Hexadecimal
Group bits in sets of 4 (starting from the right) and convert to hexadecimal digits.
Example: 111011012=ED1611101101_2 = ED_{16}111011012=ED16 - Hexadecimal to Binary
Convert each hexadecimal digit to its 4-bit binary equivalent.
Example: 1A316=00011010001121A3_{16} = 0001 1010 0011_21A316=0001101000112
Practice
Questions
- Convert 10110210110_2101102 to
decimal.
- Convert 34510345_{10}34510 to
binary.
- Convert 7F167F_{16}7F16 to
binary.
- Convert 12610126_{10}12610 to
hexadecimal.
1. Binary to Decimal
Rule: Multiply each bit by 2n2^n2n, where nnn is the position of
the bit from the right (starting from 0).
Example:
Convert 101121011_210112 to Decimal
10112=(1×23)+(0×22)+(1×21)+(1×20)1011_2
= (1 \times 2^3) + (0 \times 2^2) + (1 \times 2^1) + (1 \times 2^0)10112=(1×23)+(0×22)+(1×21)+(1×20)
=8+0+2+1=1110= 8 + 0 + 2 + 1 = 11_{10}=8+0+2+1=1110
2.
Decimal to Binary
Rule: Repeatedly divide the decimal number by 2, recording the
remainders. Write the remainders in reverse order.
Example:
Convert 131013_{10}1310 to Binary
- 13÷2=613 \div 2 = 613÷2=6
remainder 1
- 6÷2=36 \div 2 = 36÷2=3
remainder 0
- 3÷2=13 \div 2 = 13÷2=1
remainder 1
- 1÷2=01 \div 2 = 01÷2=0
remainder 1
Reading the remainders in reverse: 1310=1101213_{10}
= 1101_21310=11012
3.
Binary to Octal
Rule: Group bits in sets of 3 (from right to left) and convert
each group to its octal equivalent.
Example:
Convert 1101012110101_21101012 to Octal
- Group bits: 110110110 101101101
- Convert: 1102=68110_2 = 6_81102=68,
1012=58101_2 = 5_81012=58
1101012=658110101_2 = 65_81101012=658
4.
Octal to Binary
Rule: Convert each octal digit to its 3-bit binary equivalent.
Example:
Convert 65865_8658 to Binary
- 68=11026_8 = 110_268=1102
- 58=10125_8 = 101_258=1012
658=110101265_8 = 110101_2658=1101012
5.
Binary to Hexadecimal
Rule: Group bits in sets of 4 (from right to left) and convert
each group to its hexadecimal equivalent.
Example:
Convert 11011011211011011_2110110112 to Hexadecimal
- Group bits: 110111011101 101110111011
- Convert: 11012=D161101_2 =
D_{16}11012=D16, 10112=B161011_2 = B_{16}10112=B16
110110112=DB1611011011_2 = DB_{16}110110112=DB16
6.
Hexadecimal to Binary
Rule: Convert each hexadecimal digit to its 4-bit binary
equivalent.
Example:
Convert 3F163F_{16}3F16 to Binary
- 316=001123_{16} = 0011_2316=00112
- F16=11112F_{16} = 1111_2F16=11112
3F16=0011111123F_{16} = 00111111_23F16=001111112
7.
Decimal to Octal
Rule: Repeatedly divide the decimal number by 8, recording the
remainders. Write the remainders in reverse order.
Example:
Convert 11110111_{10}11110 to Octal
- 111÷8=13111 \div 8 = 13111÷8=13
remainder 7
- 13÷8=113 \div 8 = 113÷8=1
remainder 5
- 1÷8=01 \div 8 = 01÷8=0
remainder 1
Reading the remainders in reverse: 11110=1578111_{10}
= 157_811110=1578
8.
Octal to Decimal
Rule: Multiply each digit by 8n8^n8n, where nnn is the position
from the right (starting from 0).
Example:
Convert 1578157_81578 to Decimal
1578=(1×82)+(5×81)+(7×80)157_8 = (1
\times 8^2) + (5 \times 8^1) + (7 \times 8^0)1578=(1×82)+(5×81)+(7×80) =64+40+7=11110=
64 + 40 + 7 = 111_{10}=64+40+7=11110
9.
Decimal to Hexadecimal
Rule: Repeatedly divide the decimal number by 16, recording the
remainders. Write the remainders in reverse order.
Example:
Convert 75510755_{10}75510 to Hexadecimal
- 755÷16=47755 \div 16 = 47755÷16=47
remainder 3
- 47÷16=247 \div 16 = 247÷16=2
remainder 15 (F)
- 2÷16=02 \div 16 = 02÷16=0
remainder 2
Reading the remainders in reverse: 75510=2F316755_{10}
= 2F3_{16}75510=2F316
10.
Hexadecimal to Decimal
Rule: Multiply each digit by 16n16^n16n, where nnn is the
position from the right (starting from 0).
Example:
Convert 2F3162F3_{16}2F316 to Decimal
2F316=(2×162)+(15×161)+(3×160)2F3_{16}
= (2 \times 16^2) + (15 \times 16^1) + (3 \times 16^0)2F316=(2×162)+(15×161)+(3×160)
=512+240+3=75510= 512 + 240 + 3 = 755_{10}=512+240+3=75510
Conversion
Summary Table
From |
To |
How |
Binary |
Decimal |
Multiply bits by 2n2^n2n and sum. |
Decimal |
Binary |
Divide by 2, write remainders in
reverse. |
Binary |
Octal |
Group bits in 3's, convert to
octal. |
Octal |
Binary |
Convert each digit to 3-bit
binary. |
Binary |
Hexadecimal |
Group bits in 4's, convert to
hexadecimal. |
Hexadecimal |
Binary |
Convert each digit to 4-bit
binary. |
Decimal |
Octal |
Divide by 8, write remainders in
reverse. |
Octal |
Decimal |
Multiply digits by 8n8^n8n and
sum. |
Decimal |
Hexadecimal |
Divide by 16, write remainders in
reverse. |
Hexadecimal |
Decimal |
Multiply digits by 16n16^n16n and
sum. |
Steps to Convert Decimal to Another System
- Convert the Integer Part (e.g., 345434543454): Use the standard integer
conversion method (e.g., divide by the base and record remainders for
binary, octal, or hexadecimal).
- Convert the Fractional Part (e.g., 0.560.560.56):
- Multiply the fractional part
by the base of the target system.
- Extract the integer part of
the result as the next digit.
- Repeat the process with the
new fractional part until it becomes zero or you reach the desired
precision.
Example:
Convert 3454.56103454.56_{10}3454.5610 to Binary
Step
1: Convert Integer Part (3454103454_{10}345410)
- 3454÷2=17273454 \div 2 = 17273454÷2=1727
remainder 0
- 1727÷2=8631727 \div 2 = 8631727÷2=863
remainder 1
- 863÷2=431863 \div 2 = 431863÷2=431
remainder 1
- 431÷2=215431 \div 2 = 215431÷2=215
remainder 1
- 215÷2=107215 \div 2 = 107215÷2=107
remainder 1
- 107÷2=53107 \div 2 = 53107÷2=53
remainder 1
- 53÷2=2653 \div 2 = 2653÷2=26
remainder 1
- 26÷2=1326 \div 2 = 1326÷2=13
remainder 0
- 13÷2=613 \div 2 = 613÷2=6
remainder 1
- 6÷2=36 \div 2 = 36÷2=3
remainder 0
- 3÷2=13 \div 2 = 13÷2=1
remainder 1
- 1÷2=01 \div 2 = 01÷2=0
remainder 1
Reading remainders from bottom to
top:
345410=11010111111023454_{10} =
110101111110_2345410=1101011111102
Step
2: Convert Fractional Part (0.56100.56_{10}0.5610)
- 0.56×2=1.120.56 \times 2 = 1.120.56×2=1.12
→ Integer part 1
Fractional part = 0.120.120.12 - 0.12×2=0.240.12 \times 2 = 0.240.12×2=0.24
→ Integer part 0
Fractional part = 0.240.240.24 - 0.24×2=0.480.24 \times 2 = 0.480.24×2=0.48
→ Integer part 0
Fractional part = 0.480.480.48 - 0.48×2=0.960.48 \times 2 = 0.960.48×2=0.96
→ Integer part 0
Fractional part = 0.960.960.96 - 0.96×2=1.920.96 \times 2 = 1.920.96×2=1.92
→ Integer part 1
Fractional part = 0.920.920.92
(Continue as needed for more precision.)
Combining the results:
3454.5610=110101111110.100012(approximation)3454.56_{10}
= 110101111110.10001_2 \quad (\text{approximation})3454.5610=110101111110.100012(approximation)
Example:
Convert 3454.56103454.56_{10}3454.5610 to Hexadecimal
Step
1: Convert Integer Part (3454103454_{10}345410)
- 3454÷16=2153454 \div 16 = 2153454÷16=215
remainder 14 (E)
- 215÷16=13215 \div 16 = 13215÷16=13
remainder 7
- 13÷16=013 \div 16 = 013÷16=0
remainder 13 (D)
Reading remainders from bottom to
top:
345410=D7E163454_{10} = D7E_{16}345410=D7E16
Step
2: Convert Fractional Part (0.56100.56_{10}0.5610)
- 0.56×16=8.960.56 \times 16 =
8.960.56×16=8.96 → Integer part 8
Fractional part = 0.960.960.96 - 0.96×16=15.360.96 \times 16 =
15.360.96×16=15.36 → Integer part F
Fractional part = 0.360.360.36 - 0.36×16=5.760.36 \times 16 =
5.760.36×16=5.76 → Integer part 5
Fractional part = 0.760.760.76 (Continue as needed for more precision.)
Combining the results:
3454.5610=D7E.8F516(approximation)3454.56_{10}
= D7E.8F5_{16} \quad (\text{approximation})3454.5610=D7E.8F516(approximation)
General
Formula for Fractional Conversion
For a fractional decimal value XXX:
- Multiply XXX by the target
base.
- Take the integer part as the
next digit.
- Repeat with the fractional
part.
This process works for any base
(binary, octal, hexadecimal).
Step 1: Convert the Integer Part (1001102100110_21001102)
Use the positional value of binary
digits (2n2^n2n):
1001102=(1×25)+(0×24)+(0×23)+(1×22)+(1×21)+(0×20)100110_2
= (1 \times 2^5) + (0 \times 2^4) + (0 \times 2^3) + (1 \times 2^2) + (1 \times
2^1) + (0 \times 2^0)1001102=(1×25)+(0×24)+(0×23)+(1×22)+(1×21)+(0×20) =32+0+0+4+2+0=38=
32 + 0 + 0 + 4 + 2 + 0 = 38=32+0+0+4+2+0=38
Step
2: Convert the Fractional Part (0.0110120.01101_20.011012)
Each digit after the binary point
represents a negative power of 2 (2−n2^{-n}2−n):
0.011012=(0×2−1)+(1×2−2)+(1×2−3)+(0×2−4)+(1×2−5)0.01101_2
= (0 \times 2^{-1}) + (1 \times 2^{-2}) + (1 \times 2^{-3}) + (0 \times 2^{-4})
+ (1 \times 2^{-5})0.011012=(0×2−1)+(1×2−2)+(1×2−3)+(0×2−4)+(1×2−5) =0+0.25+0.125+0+0.03125=0.40625=
0 + 0.25 + 0.125 + 0 + 0.03125 = 0.40625=0+0.25+0.125+0+0.03125=0.40625
Step
3: Add the Integer and Fractional Parts
100110.011012=38+0.40625=38.4062510100110.01101_2
= 38 + 0.40625 = 38.40625_{10}100110.011012=38+0.40625=38.4062510
Final
Answer
100110.011012=38.4062510100110.01101_2
= 38.40625_{10}100110.011012=38.4062510
Comments
Post a Comment