Professional Documents
Culture Documents
ZKYC77
Digital Electronics
Prof. Dr. Leitis,
THM Technische Hochschule Mittelhessen,
University of Applied Sciences
Friedberg
1
2 Number Systems and Binary Arithmetic
n−1
i n−1 n−2 1 0
Z = ∑ C i⋅B =C n−1⋅B
−1 −m
C n−2⋅B ...C 1⋅B C 0⋅B C −1⋅B ...C −m cdt B
i =−m
Examples
27 D = 20 7 = 2⋅101 7⋅100
3
2 Number Systems and Binary Arithmetic
n−1
i
Conversion binary to decimal numbers: Z 10 =∑ C i⋅2 c={0,1 }
i =0
S 1=C n−1 Z
=S 1 C1
B Remainder
S 2 =S 1⋅BC n−2 S1
=S 2 Remainder C2
B
S 3 =S 2⋅BC n−3 S2
=S 3 Remainder C3
B
⋮ ⋮
S n−1 =S n−2⋅BC 1 S n−2
=S n−1 Remainder
B C n−2
S n =S n−1⋅BC 0 S n−1
=S n Remainder C n−1
B
Z =S n 4
2 Number Systems and Binary Arithmetic
Decimal
Binary Number
Number
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1 5
2 Number Systems and Binary Arithmetic
Decimal number
6
2 Number Systems and Binary Arithmetic
Exercises in a nutshell
Exercises in a nutshell
738= ???2
7538=???10
1000002=???8
6310=???8
738= 1110112
7538=49110
1000002=408
6310=778
9
2 Number Systems and Binary Arithmetic
Exercises in a nutshell
10
2 Number Systems and Binary Arithmetic
Decimal Binary
Number Number
● Representation of signs (negative numbers) system System
in binary numbers:
+ 0
(only „0“ and „1“ are available) - 1
11
2 Number Systems and Binary Arithmetic
Example: 2610
(+) 0↓ 1
↓
1
↓
0
↓
1
↓
0
↓
=
( -) 1 0 0 1 0 1 = -2610
12
2 Number Systems and Binary Arithmetic
Example: 0 1 1 0 1 0 = 3110
↓ ↓ ↓ ↓ ↓ ↓
1 0 0 1 0 1 = One's complement
+1 1 0 0 1 1 0 = Two's complement
● Complementing by subtraction
2.5.1 Binary Addition
a b sum carry
Truth table for 0 0 0 0
0+0=0
0+1=1 the addition 0 1 1 0
1+0=1 of two single bits 1 0 1 0
1 + 1 = 0 + Carry (half adder) 1 1 0 1
Addition of a 4bit vector Full adder truth table and circuit
c4 c3 c2 c1 carry CIN A B S CO
0 0 0 0 0
0 0 1 1 0
a3 a2 a1 a0
+
0 1 0 1 0
0 1 1 0 1
b3 b2 b1 b0 1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
s4 s3 s2 s1 s0 sum
1 1 1 1 1
14
2.5 Binary Arithmetic
Exercises in a nutshell
1101 111101 1 1 0 0, 1 1
+ 100 + 1001 + 1 1 1, 0 1
????? ????? ?????
1101 111101 1 1 0 0, 1 1
+ 100 + 1001 + 1 1 1, 0 1
10001 1000110 10100,00
15
2.5 Binary Arithmetic
2.5.2 Binary Subtraction
M(inuend) S(ubtrahend) D(ifference) B(orrow)
0–0=0 0 0 0 0
1–0=1 0 1 1 0
1–1=0 1 0 1 0
0–1=1 + borrow 1 1 0 1
Truth table for the subtraction
Half subtractor circuit (no borrow bit input)
of two single bits
Subtraction of a 4bit vector Or adding two's complement of the subtrahend
B4 B3 B2 B1 Borrow c4 c3 c2 c1 carry
M3 M2 M1 M0 a3 a2 a1 a0
D 4 D3 D2 D 1 D0 Difference D4 D3 D2 D1 D0 Difference
16
2.5 Binary Arithmetic
2.5.3 Binary Multiplication
a b Product
Truth table for the multiplication
0 0 0
0 1 0
of two single bits.
1 0 0 Hint: rules are identical to decimal number system
1 1 1
b3 b2 b1 b0 x a3 a2 a1 a0
17
2.6 Codes
Representation of Decimal Numbers
19
2.6 Codes
Representation with Codes → BCDCode
BCD (binary coded decimal) or 8421 Code
20
Representation with Codes → GrayCode
21
2.6 Codes