Number Systems
Number Systems
• Binary numbers
–Digits = {0, 1}
– (11010.11) 2 = 1 x 2 4
+ 1 x 2 3
+ 0 x 2 2
+ 1 x 21 + 0 x 20 + 1 x 2-1 + 1 x 2-2
= (26.75)10
• Octal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7}
– (127.4)8 = 1 x 82 + 2 x 81 + 7 x 80 + 4 x 8-1 = (87.5)10
• Hexadecimal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
– (B65F)16 = 11 x 163 + 6 x 162 + 5 x 161 + 15 x 160 =
(46,687)10
Important Number Systems
Decimal Binary Octal Hexadecimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 1 F
16 10000 20 10
CONVERSIONS
DECIMAL TO OTHER
1. DECIMAL TO BINARY
Decimal Number System to Other Base To convert Number system from Decimal Number
System to Any Other Base is quite easy; you have to follow just two steps: A) Divide the
Number (Decimal Number) by the base of target base system (in which you want to
convert the number: Binary (2), octal (8) and Hexadecimal (16)). B) Write the remainder
from step 1 as a Least Signification Bit (LSB) to Step last as a Most Significant Bit (MSB).
2. DECIMAL TO OCTAL
3. DECIMAL TO HEXADECIMAL
BINARY TO OTHER
1. BINARY TO DECIMAL
Shortcut method
• Binary Arithmetic
+ Addition
111011 Carries
101011 Augend
+ 11001 Addend
1000100
– Subtraction
0 1 10 0 10 Borrows
1 0 0 1 0 1 Minuend
- 1 1 0 1 1 Subtrahend
1 0 1 0
Multiplication Division
1 1 0 1 0 Multiplicand
110 Quotient
x 1 0 1 0 Multiplier
Divider 1 0 0 1 111101 Dividend
00000
11010 1001
00000 1100
11010 1001
111 Remainder
1 0 0 0 0 0 1 0 0 Product
Python Code:
print()
print(ord('a')) print(ord('A'))
print(ord('1')) print(ord('@'))
print()
Sample Output:
97
65
49
64