Machine_structure_Chapter 2
Machine_structure_Chapter 2
Presented by:
Dr. BEN SI SAID KARIM
Grade: Associate Professor
[email protected] Department: Computer Science
Faculty: Faculty of Sciences
University: Algiers 1
Machine Structure I: Represents one of the fundamental pillars that any student aspiring to delve
into computer science must master. This module provides a crucial foundation for understanding the
functioning of computers and digital systems.
Target Audience: 1st year Bachelor’s students, in Computer Science or eletronics
Course : Fundamental unit
Credits : 05
Coefficient : 03
Semester : 01 / 14 weeks
Sessions duration: 1h 30 per week:
Course code:
rgps3on
✓ Understand the basics of numeral systems (Decimal, Binary, Octal and Hexadecimal)
✓ Apply different conversion between numbers from a base to another
✓ Perform the basic arithmetic operations in binary for integers and fractional numbers
(Addition, Subtraction, Multiplication and Division)
Example
140,360: one hundred forty thousands, three hundred sixty
368: three hundred sixty-eight
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 9
Chapter- II : Numeral system --> Decimal
Integer Fractional
Example part part
Polynomial form
• Every decimal number can be written in the polynomial form.
• The overall value of the number is obtained by summing the values of each digit
multiplied by the appropriate powers of the decimal base 10.
Example
436 = 400 + 30 + 6 = 4 x 100 + 3 x 10 + 6 x 1 = 4 x 102 + 3 x 101 + 6 x 100
128.71 = 1x102 + 2 x 101 + 8 x 100 + 7 x 10-1 + 1 x 10-2
n−1
NB = ai B i
i= −p
Where ai are the digits of the number, Bi the power of the digit (i), and n, p are the number of digits
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 11
Chapter- II : Numeral system --> Decimal
Notes
• A numbering system consists of specific rules and symbols that enable the
representation of quantitative information. It is based on 3 aspects:
• The base : refers to a value that dictate the weight (power) of digits. (example
with the previous number (128.71)10 in decimal base (10)
• A set of symbols and/or characters used to represent a quantity
(example 0,1,2,3,4,5,6,7,8,9)
• Rules. For example: rule1 the number of characters should be less than the base
(in decimal base we have 10 characters => 0 → 9 < 10). Rule2 : when writing, the
position of the digits (0123. 0153: position of 0 is not significant in 0123 but
important in .0153)
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 12
Chapter- II : Numeral system --> Other numeral systems
Exercise
• Write the power of each digit for the following numbers:
(1101.101)2, (5AD.0C)16, (13.21)4, (734.5)8
Counting possibilities
• In a given base B, the number of counting possibilities P is function of the base B and the
number of digits D
P = BD
Examples
• In decimal with 2 digits, we can write 102 = 100 values: 0→(99)10
• In decimal with 3 digits, we can write 103 = 1000 values 0→(999)10
Exercise
• How much RAM memory we can handle with a 32-bit system ?
232 = 4,294,967,296 = 4 Gigabytes (GByte)
• 1 nibble = 4 bits
• 1 Byte = 1 octet = 8 bits
• 1 byte (8 bits) can represent a character (e.g., a letter, number, or symbol).
• 1 kilobyte (KB) is approximately 1,024 bytes (or 8,192 bits).
• 1 megabyte (MB) is approximately 1,024 KB (or 8,388,608 bits).
• 1 gigabyte (GB) is approximately 1,024 MB (or 8,589,934,592 bits).
Examples
• (A5)16 = A x 161 + 5 x 160 = 10 x 16 + 5 x 1 = 165
2
• (73.2)8 = 7x81 + 3x80 + 2x8-1 = 56 + 3 + 8 = 59.25
2 2
• (32.22)4 = 3x41 + 2x40+ 2x4-1 + 2x4-2 = 12+2+ 4 + 16 = 14.625
(0.74)10 = (0.10111)2
0.74 x 2 = 1.48
0.48 x 2 = 0.96
0.96 x 2 = 1.92 → 13.74 = (1101. 10111)2
0.92 x 2 = 1.84
1101
0.84 x 2 = 1.68
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 24
Chapter- II : Conversion between bases
❖ Conversion Decimal- base B - decimal
• The conversion from a base B to decimal, or from decimal to another base can be illustrated using a
balance taking the decimal number in one pan, and the powers and weights of the bases in the other.
• In the following example, we have 7 digits of base 2 (binary) with the weights:
➢ 20 = 1, 21 = 2, 22 = 4, 23= 8, and 24 = 16, for the integer part
➢ 2 digits with weights 2-1 = 0.5, and 2-2 = 0.25 for the fractional part.
• To make the number 5.75 in binary, we take the bits representing the power of 22 = 4, 20 = 1 for the Integer
part and 2-1 = 0.5, and 2-2 = 0.25 for the fractional.
• In binary, we have only one piece of each weight (we can use it: (1), or not: (0))
23 20 2-2
5.75 24 21
0.5
16 8 4 2 1 22
24 23 22 21 20 2−1 2 −2 5= 00101.11
Decimal Binary
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 25
Chapter- II : Conversion between bases
❖ Conversion Decimal- base B - decimal
• In binary, we have only one piece of each weight (we can use it: (1), or not: (0))
• In other bases there are more than one sample of each weight (7 pieces in octal, and 15 in hexadecimal)
Example 1: To form (10)10 in octal, we use two weights of 80 = 1, and one weight 81 = 8
Example 1: To form (138)10 in octal, we use two weights of 80 = 1, one weight 81 = 8 and two weights 82 = 64
80
10 81
10 =(12)8
Decimal Octal 82 81 80
80
81 64
82 8 1
138
138 =(212)8
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 26
Decimal Octal
Chapter- II : Conversion between bases
12 3 (12)10 = (110)3
0 4 3 ?
B1 B2
1 1 3
1 0
→ (22)5 = (12)10 = (110)3
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 27
Chapter- II : Conversion between bases
4. Binary – hex
Hex(16) Bin (2)
To convert from binary to hexadecimal, we group every 4 bits in the binary 0 0000
representation and convert each group to its respective hexadecimal digit 1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
Example 9 1001
A 1010
11101.010101 = 0001 1101. 0101 0100 = 0x1D.54 B 1011
C 1100
111111.11001 = 0011 1111. 1100 1000 = 0x3F.C8 D 1101
E 1110
F 1111
multiplier
Minuend
Subtrahend
1. Addition
Addition in binary is identical than in decimal, it relays
on 4 rules:
Example 110 6
+
1110 100 4
1110 14 1010 10
+ 110 6
10100 20
Exercise: Add the following binary numbers:
• 1+1+1+1 = 100
• 11 + 11 = 110
• 111 + 11 = 1010
• 110 + 100 = 1010 Copyright © Karim Ben Si Said L1 – INFO -2024/2025 32
Chapter- II : Arithmetic operations
2. Subtraction
• Subtraction in binary is identical to decimal. We use the
following rules
• When a borrow is required (0-1 case), we look at the
next column to the left.
110 6
• when a 1 is borrowed from the next column to the left, -
100 4
a 10 is created in the column being subtracted, and the
column from where 1 is taken becomes 0. 010 2
Example
0
We borrow 1 from the 3rd column of 1 0 1 to the 2nd column, it
becomes (0 10 1)
Column 3rd 2nd 1st
-
Before borrowing 1 0 1
After borrowing 0 10 1
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 33
Chapter- II : Arithmetic operations
2. Subtraction
Examples
• When we borrow 1 from a column containing 10, it becomes 10-1 = 1
The following table shows the steps to calculate 1010 – 111
Exercise
Calculate 24- 1 = (11000)2 – (1)2
3. Multiplication
• When we perform a multiplication between two binary numbers,
we perform a partial products between each bit of the first
number by the second number.
Example
Exercise
Calculate 15.1 x 3 in binary
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 35
Chapter- II : Arithmetic operations
4. Division Dec (10)s Bin (2)
• The division in binary follows the same procedure as division 0 00000
1 00001
in decimal 2 00010
3 00011
4 00100
Example 5 00101
6 00110
7 00111
1111 101 8 01000
-
101 11 9 01001
10 01010
0101 11 01011
-
101 12 01100
0 78 4 13 01101
15 5 14 01110
19.5 15 01111
3
16 10000
17 10001
18 10010
19 10011
Copyright © Karim Ben Si Said L1 – INFO -2024/2025 20 1010036
Chapter- II : Arithmetic operations
5. Addition in octal
• Addition in octal is identical than in decimal: if the sum of first digits is
greater than 7, add the carry to the adjacent digit to left
Oct Dec
10
71 57
+
27 23
120 80
Example
1 dec
AF 175
+
21 33
D0 208
38
➢ BY THE END OF THIS CHAPTER,
• Perform the basic arithmetic operations in binary for integers and fractional numbers
(Addition, Subtraction, Multiplication and Division)