Digital I Summaries - Appendix I - Bases, Conversions, Complements, Representations, and Operations
Digital I Summaries - Appendix I - Bases, Conversions, Complements, Representations, and Operations
Youcef Harmouni
1 Definitions 5
1.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Extra : Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 Representations 9
2.1 Bases Where 0 < b ≤ 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Bases Where 10 < b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 Conversions 11
3.1 Sum of weights representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Base 10 to Base b . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Base b to Base 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Base 2 to Base 2n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.5 Base 2n to Base 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Complements 15
4.1 Sign Magnitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2 Radix’s Complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 One’s Complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.4 Two’s Complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3
4 CONTENTS
Chapter 1
Definitions
1.1 Definitions
Base (Radix) : Set of symbols & values used to represent given numbers (Most commonly found bases are 2,
8, 10 and 16)
Analog Signal : type of electrical signal that can be represnted by a continous function (infinite amount of
values) eg : 1.99, 6.77, 22/7...
Digital Signal : type of electrical signal that can be represnted by a non-continous/ Discrete function (finite
amount of values) eg :0, 1
Integer # : Numbers that do not contain decimal (floating) point in them. eg : 10, 16, 256, 1024...
Fractional # : Numbers that contain decimal point in them. eg : 3.14, 1.618, 420.69
Mantissa : Generally, mantissa is the scientific notation of a given number without its exponent. In binary it’s
the part after the decimal point in fractional numbers.
X’s Complement ([N ]X ) : X’s complement of N is a special number that when added to N should yield out
digits of X itself. thus “completes” it (9’s complement of 69 is 30, 69+30 = 99) with Noting that X = b-1
BCD (Binary coded Decimal) : Special binary system that deals with binary numbers with decimal’s range
(See Figure 1.1)
GRAY : Special binary system that rearranges binary numbers so it increases one bit at a time (See Figure
1.2)
ASCII : Special binary system that uses binary numbers as a code to resemble digits, character, symbols etc.
(See Figure 1.3)
5
6 CHAPTER 1. DEFINITIONS
Representations
Example :
b = 2 → R{b} = {0, 1}
b = 4 → R{b} = {0, 1, 2, 3}
Example :
9
10 CHAPTER 2. REPRESENTATIONS
Chapter 3
Conversions
Where :
N : Number
S : Sign of the number(1, −1)
b : Base of the number
a : Certain coefficient (a < b)
Example :
(−420)8 = −1(4 · 82 + 2 · 81 + 0 · 80 )
Note : You can represent fractional numbers using the same method, but starting from negative number , not 0.
Also, when rounding a number of base b, Compare it to 2b and perform the rounding.
11
12 CHAPTER 3. CONVERSIONS
15/16 = 0 + 15
Therefore :
(4043)10 → (F CB)16
Note : To convert fractional numbers, You must first separate the mantissa from the number and then perform
multiple multiplications and collect each integer part. only stopping when the number is fully integer.
Example :
(25.25)10 → (?)8
Converting the Integer part :
25/8 = 3 + 1
03/8 = 0 + 3
(25)10 → (31)8
Converting the Fractional part :
0.25 · 8 = 2 + 0
Therefore :
(25.25)10 → (31.2)8
(11001100)2 → (?)16
Note : If there’s no enough bits to convert, we consider the needed bits as 0’s. And in the case of fractions, you
start counting from the fractional point.
Example 1 :
(10111)2 → (?)8
(10111)2 = (010)(111) = (27)8
Therefore :
(10111)2 = (27)8
Example 2 :
(110.1)2 → (?)16
(110.1)2 = (0110).(1000) = (6.8)16
Therefore :
(110.1)2 → (6.8)16
Note : You can generalize the two methods above to convert from b to bn (Or the inverse)
14 CHAPTER 3. CONVERSIONS
Chapter 4
Complements
(−16)10 → (110000)2
Example 1 :
Example 2 :
15
16 CHAPTER 4. COMPLEMENTS
(−0)10 → (?)2
Sign Magnitude : (0000)2 → (10000)2
Inverting : (10000)2 → (11111)2
Add one to the right most bit (including the sign bit)
(−0)10 → (?)2
One’s complement : (0000)2 → (11111)2
Adding One : (11111)2 → (00000)2
Note : As you’ve noticed in the previous example. the Two’s complement of 0 is 0 itself, thus extending its range
for one more number. that’s the reason behind choosing Two’s complement in most of our digital system and not its
counterparts.
Chapter 5
S : Sign
M : Mantessa
b : Base
E : Exponent
Example :
17
18 CHAPTER 5. BINARY FLOATING POINT
52 Bit : The mantissa (integer part emitted, the unused bits are 0)
Example :
−1100111100 = −1 · (1.100111100 · 29 )
1 Sign bit :(1)2
11 Exponent bit : 9 + 1023 = (1032)10 = (10000001000)2
52 Exponent bit : = (10011110000...)2
Put together : = (1 − 10000001000 − 10011110000...)2
64 Bit : The mantissa (integer part emitted, the unused bits are 0)
Example :
−1011 = −1 · (1.011 · 23 )
1 Sign bit :(1)2
15 Exponent bit : 3 + 16383 = (16386)10 = (1000...0010)2
64 Exponent bit : = (0110000000...)2
Put together : = (1 − 1000...0010 − 0110000...)2
Note : As you may’ve noticed, it’s time wasting to type all those bits with precision, that’s why some digital systems
use Hexadecimal for these methods.
Chapter 6
N =a·P ·b
19