0% found this document useful (0 votes)
23 views19 pages

Digital I Summaries - Appendix I - Bases, Conversions, Complements, Representations, and Operations

Uploaded by

xaredev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views19 pages

Digital I Summaries - Appendix I - Bases, Conversions, Complements, Representations, and Operations

Uploaded by

xaredev
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Digital Systems I

Appendix I : Conversions, Complements,


Representations, and Operations.

Youcef Harmouni

October 14, 2024


Contents

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

5 Binary Floating point 17


5.1 General Formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.2 Single Precision Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.3 Double Precision Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.4 Extended Precision Floating Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

6 Special Binary codes 19


6.1 Binary Units of Measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

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)

ˆ Bit: Binary Digit, smallest form of the binary system

ˆ Nibble : Set of 4 bits

ˆ Byte : Set of 8 bits

ˆ 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

ˆ # : Symbol for numbers (to eliminate repetition)

ˆ 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.

ˆ Signed # : Numbers that either hold a postive or negative sign on them.

ˆ 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

1.2 Extra : Figures

Figure 1.1: Decimal V.S Binary V.S BCD Table.


1.2. EXTRA : FIGURES 7

Figure 1.2: Decimal V.S Binary V.S GRAY Table.


8 CHAPTER 1. DEFINITIONS

Figure 1.3: Decimal V.S Hex V.S ASCII Table.


Chapter 2

Representations

2.1 Bases Where 0 < b ≤ 10


For each Base 0 < b ≤ 9 , its digits range is :

R{b} = {0, 1, 2, ..., (b − 1)}

Example :
ˆ b = 2 → R{b} = {0, 1}

ˆ b = 4 → R{b} = {0, 1, 2, 3}

ˆ b = 10 → R{b} = {0, 1, 2, ..., 9}

2.2 Bases Where 10 < b


After b > 10, we start using alphabatical letters to resemble numbers.

Example :

ˆ b = 11 → R{b} = {0, 1, 2, ..., 9, A}

ˆ b = 12 → R{b} = {0, 1, 2, ..., 9, A, B}

ˆ b = 16 → R{b} = {0, 1, 2, ..., 9, A, ..., F }

Note : Number N of the base b → (N )b

9
10 CHAPTER 2. REPRESENTATIONS
Chapter 3

Conversions

3.1 Sum of weights representation


Any number of the base b can be represented as :
i=n
X
N = S · (a0 · b0 + a1 · b1 + ...an · bn ) = S · ai · bi
i=0

Where :

N : Number
S : Sign of the number(1, −1)
b : Base of the number
a : Certain coefficient (a < b)

Example :

ˆ (128)10 = 1(1 · 102 + 2 · 101 + 8 · 100 )

ˆ (−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.

ˆ (3.14)10 = 1(3 · 100 + 1 · 10−1 + 4 · 10−2 )

ˆ (−420.69)32 = −1(4 · 322 + 2 · 321 + 0 · 320 + 6 · 32− 1 + 9 · 32− 2)

3.2 Base 10 to Base b


We can go from base 10 to any base b by performing multiple divisions and collect each remainder finish to start
Example :
(4043)10 → (?)16
4043/16 = 252 + 11
252/16 = 15 + 12

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

3.3 Base b to Base 10


We can go from base b to any base 10 by using sum of weight representation of that number
Example :
(10100)2 → (?)10
(10100)2 = 24 + 22 = 16 + 4 = 20
Therefore :
(10100)2 → (20)10

-Your mark in Digital inshallah !-

3.4 Base 2 to Base 2n


We can convert from base 2 to base 2n by converting n bits to one digit of that base directly Example :

(11001100)2 → (?)16

(11001100)2 = (1100)(1100) = (CC)16


Therefore :
(11001100)10 → (CC)16
3.5. BASE 2n TO BASE 2 13

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

3.5 Base 2n to Base 2


We can convert from base 2n to base 2 by converting one digit of that base to n bits directly Example :

(F AC)16 → (?)2 → (?)10

(F AC)16 = (1111)(1010)(1100) = (111110101100)2


(F AC)16 = (1111)(1010)(1100) = (111110101100)2
(111110101100)2 = (4012)10
Therefore :
(F AC)16 → (111110101100)2 → (4012)10

Note : You can generalize the two methods above to convert from b to bn (Or the inverse)
14 CHAPTER 3. CONVERSIONS
Chapter 4

Complements

4.1 Sign Magnitude


To denote Negative values in binary systems, we must add an additional bit in front our original bit called “Sign Bit”
to differentiate between positive and negative values
Example :
(+16)10 → (010000)2

(−16)10 → (110000)2

4.2 Radix’s Complement


For a number of the base b. to find its r’s complement we must first find its (r-1)’s complement first and add one to
the right most digit

Example 1 :

9’s Complement of (45)10 : [45]9 = 54

10’s Complement of (45)10 : [45]9 + 1 = 54 + 1 = 55

Example 2 :

7’s Complement of (77.6)8 : [77.6]7 = 00.1

8’s Complement of (77.6)8 : [77.6]9 + 1 = 00.1 + 1 = 00.2

4.3 One’s Complement


To denote the negative value in binary systems using One’s complement you must :

ˆ Do the Sign Magnitude representation of the number

ˆ Inverse the resulted number (not including the sign bit)

15
16 CHAPTER 4. COMPLEMENTS

Example : -0 in one’s complement

(−0)10 → (?)2
Sign Magnitude : (0000)2 → (10000)2
Inverting : (10000)2 → (11111)2

4.4 Two’s Complement


To denote the negative value in binary systems using Two’s complement :

ˆ Do the One’s complement of the number

ˆ Add one to the right most bit (including the sign bit)

Example : -0 in Two’s complement

(−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

Binary Floating point

5.1 General Formula


Generally, a floating number N can be represented using the following formula :
N = S · (M · bE )
With :

S : Sign
M : Mantessa
b : Base
E : Exponent

Example :

196.2 = +1 · (1.962 · 102 )


19.54 = +1 · (1.954 · 101 )
−110011 = −1 · (1.10011 · 25 )

5.2 Single Precision Floating Point


This method allocates 32 bits as follows :
ˆ 1 Bit : Sign Bit
ˆ 8 Bit : The exponent + 127
ˆ 23 Bit : The mantissa (integer part emitted, the unused bits are 0)
Example :
110011 = +1 · (1.10011 · 25 )
1 Sign bit :(0)2
8 Exponent bit : 5 + 127 = (132)10 = (10000100)2
23 Exponent bit : = (100110000...)2
Put together : = (0 − 10000100 − 10011000...)2

17
18 CHAPTER 5. BINARY FLOATING POINT

5.3 Double Precision Floating Point


This method allocates 64 bits as follows :
ˆ 1 Bit : Sign Bit

ˆ 11 Bit : The exponent + 1023

ˆ 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

5.4 Extended Precision Floating Point


This method allocates 80 bits as follows :
ˆ 1 Bit : Sign Bit

ˆ 15 Bit : The exponent + 16383

ˆ 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

Special Binary codes

6.1 Binary Units of Measurements


In binary, to express a number in units you should write it as :

N =a·P ·b

P : Prefixes : Ki : 210 , M i : 220 , Gi : 230 ..


b : Bit (or Byte) : b : 20 , B : 23
a : a certain coefficient

Example : Write the following numbers using Units of Measurements :

245 , 212 , 233


245 = 240 · 23 · 22 = 22 T iB = 4T iB = 4 · 23 T ib = 32T ib
212 = 210 · 22 = 4Kib
233 = 230 · 23 = 1GiB = 1 · 23 Gib = 8Gib

19

You might also like