Professional Documents
Culture Documents
CH1 - Number System
CH1 - Number System
Lecture - 01
Md. Zubair Alam
https://youtu.be/XTAsBQgxVGg
Numbers
• Decimal Number
7392 = 7 x 103 + 3 x 102 + 9 x 101 + 2 x 100
• In general decimal numbers are written as
a3a2a1a0.a-1a-2
= 103a3 + 102a2 + 101a1 + 100a0 + 10-1a-1 + 10-2a-2
• Decimal number system is of base, or
radix, 10 because it uses 10 digits and the
coefficients are multiplied by powers of 10.
Binary Number
• Binary system is a different number
system whose base (radix) is 2.
• It has only 2 coefficients: 0 and 1
• Coefficients are multiplied by power of 2.
11.112 = 1 x 21 + 1 x 20 + 1 x 2-1 + 1 x 2-2 = 3.7510
(110101)2 = 32 + 16 + 4 + 1 = (53)10
• In computer work:
210 = K(ilo), 220 = M(ega), 230 = G(iga), 240 = T(era)
• byte = 8 bits (≈ one keyboard character)
Binary Number
2n - 1 -> ‘n’ number of 1’s
Example:
• 23 - 1= 8 – 1= 7 -> 111
• 28 - 1= 256 – 1= 255 -> 11111111
Octal & Hexadecimal
• Octal
– Base (or radix) 8
– Total of 8 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
– Base (radix) 16
– Total 16 digits ( 0, 1,…, 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
Numbers with different Bases
Decimal to Others
2 41
8 153
2 20 – 1
8 19 – 1
2 10 – 0
8 2–3
2 5–0
0–2 2318
2 2–1
2 1–0
101001 15310 = 2318
0–1
4110 = 1010012
OVERFLOW
Binary Subtraction
• Using 2’s complement method
– Represent the subtrahend in 2’s complement
form and simply add to the minuend.
• A – B = A + (-B) = A + 2’s complement of B
– Make sure there is no overflow
7 0111
x 3 0011
------- -------------------
21 0111
0111x
0000xx
0000xxx
-------------------
00010101
Binary Division
• Shift and subtract as in primary school again.
Binary Codes
• BCD
– Binary Coded Decimal
– Codes 0~9 using 4-bit unsigned binary representation 0000 thru 1001
(185)10 = ( 0001 1000 0101)BCD = (10111001)2
– Code words 1010 thru 1111 are not used
• BCD Addition
– Similar to adding 4-bit unsigned binary
– A correction must be made if result exceeds 1001
– Correction is made by adding 6 (i.e. 0110)
https://youtu.be/4Qc5aRKD9S4
BCD Addition
1010
which is
10 in
decimal >
1001 (9)
Add 0110
(6) to
correct
Binary Codes
• Gray Code
– Only 1-bit changes between
two neighboring numbers
– This prevents any unknown
state while transitioning.
Example: 1 1 1
1 0 0
Binary Codes
• BCD (8421)
• Excess 3-Code
• 2421
• 1-out-of-n code
• ASCII(American
Standard Code
for Information
Interchange)
Code
• 8421 and 2421 are weighted codes.
https://youtu.be/iMq_bAKhRv8
Decimal to Excess-3
• Convert 25 to Excess-3
Solution: Individual add 3 to each digit.
2 5
3 3
-------------------------
5 8
(0101 1000)
Excess-3
ASCII Code
• The ASCII code also contains 94 graphic
characters that can be printed and 34
nonprinting characters used for various control
functions.
• The graphic characters consist of the 26
uppercase letters (A through Z), the 26
lowercase letters (a through z), the 10 numerals
(0 through 9), and 32 special printable
characters, such as %, *, and $.
Error Detecting Code – Parity
• Parity bit is used to make the code to have even or odd
number of 1’s
• There are 2 types of parity
– Even
– Odd
• Parity bit is used for checking/correcting errors during
transmission of data between two computers.
Odd/Even Parity
Example
Type of bit parity error Failed transmission scenario
AND OR NOT
x y x.y x y x+y x x’
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
Logic Gates
x z = x.y x z = x+y x z = x’
y y
z = x.y
z = x+y
z = x’
XOR Gate
• If two inputs are same then output is 0 (low), else output
is 1 (high).
• C = A + B = AB+AB
HW
• 1.2, 1.3(d), 1.4, 1.6, 1.7, 1.8, 1.9(c,d,e), 1.12, 1.14(b,f,h),
1.16, 1.18(a,c), 1.23, 1.27, 1.29, 1.31~1.34