NUMBER SYSTEM _DIGITAL FUNDAMENTAL AND COMPUTER ARCHITECTURE
NUMBER SYSTEM _DIGITAL FUNDAMENTAL AND COMPUTER ARCHITECTURE
COMPUTER ARCHITECTURE
Prepared by
Poornima S
UNIT 1 NUMBER SYSTEM
Basics of Number system. Decimal, Binary, Octal and
Hexadecimal. Binary addition, subtraction, Multiplication,
Division – Conversions-Floating point representation,
Complements: 1’s complement and 2s complement addition and
subtraction
2
NUMBER SYSTEM
7
Decimal Binary(22+21+20) Octal
0 000 0
1 001 1
2 010 2
3 011 3
4 100 4
5 101 5
6 110 6
7 111 7
8
HEXADECIMAL NUMBER SYSTEM
9
10
11
NUMBER SYSTEM CONVERSIONS
There are many methods or techniques which can be used to
convert numbers from one base to another.
12
DECIMAL CONVERSION
Convert decimal numbers to binary
LSB
MSB
13
The remainders have to be arranged in the reverse order
the first remainder becomes the Least Significant Bit (LSB)
the last remainder becomes the Most Significant Bit (MSB).
14
Floating Point Conversion
15
Convert decimal numbers to Octal
To convert a decimal number to octal, we have to divide the
decimal number by 8 repeatedly and collect the remainders from
bottom to top (i.e) MSD to LSD.
LSD
MSD
16
Floating Point Conversion
The whole number part is divided repeatedly by 8
The fractional part is Multiplied repeatedly by 8
17
Convert decimal numbers to Hexadecimal
To convert a decimal number to Hexadecimal,divide the decimal
number by 16 repeatedly and collect the remainders from bottom to top (i.e)
MSD to LSD
(910)10=(38E)16
LSD
14
MSD
18
Floating Point Conversion
The whole number part is divided repeatedly by 16
The fractional part is Multiplied repeatedly by 16
19
BINARY CONVERSION
Binary to Decimal
Formula
n = bnq + bn-1qn-2 +………+ b2q2 +b1q1 +b0q0 + b-1q-1 + b-2q-2
Where,
•n is Decimal Equivalent
•b is the Digit
•q is the Base Value
21
Binary to Octal
22
Binary to Decimal Then Decimal to Octal
(1111)2 = (______)8
(1111)2 = 23 × 1 + 22 × 1 + 21 × 1 + 20 × 1 = (15)10
(15)10 = (1111)2
(1111)2 = (17)8
23
Direct Method for Binary to Octal Conversion
1. Take the given binary number and form the group of three bits
24
Note:
before the radix point (.)- Start forming the group from the LSB bit
after the radix point, start forming the group of three bits from the
immediate bit after the radix point(.)
While forming the group, number of bits is less than 3 and bit is before
the radix point, then, add 0s before the fewer bits
While forming the group the number of bits is less than 3 and bit is after
the radix point, then, add 0s after the fewer bits.
25
Convert (111010. 1001)2 = (____)8
26
Binary to Hexadecimal Conversion
27
28
Binary to Decimal Then Decimal to Hexadecimal
(1110)2 = (_______)16
(1110)2 = 23 × 1 + 22 × 1 + 21 × 1 + 20 × 0 = 8 + 4 + 2 + 0 = (14)10
(14)10 = (E)16
29
Direct Method for Binary to Hexadecimal Conversion
1. Take the given binary number and form the group of four bits
Example
1110 1111
after the radix point, start forming the group of four bits from the
immediate bit after the radix point(.)
While forming the group, number of bits is less than 4 and bit is before
the radix point, then, add 0s before the fewer bits
While forming the group the number of bits is less than 4 and bit is after
the radix point, then, add 0s after the fewer bits.
31
Example: (11101111.111001)2 = (EF.E4)16
32
OCTAL CONVERSION
Octal to decimal
33
FLOATING POINT REPRESENTATION
I. 178 to Decimal
= (1 ×81 + 7 × 80)
= 8 +7
= (15)10
178 = 11112
35
ii. (15) to Binary
2.Direct Method for Octal to Binary Conversion
1 7
0011112
001 111
36
Octal to Hexadecimal
I. 178 to Decimal
= (1 ×81 + 7 × 80)
= 8 +7
= (15)10
1615
0 - 15 F
37
17 F
Octal to Binary then Binary to Hexadecimal
I. 178 to Binary
1 = > 001
7 => 111
=> 001111
II. (001111)2 to Hexadecimal
0 15
=> ( 15 )16
15 equivalent alphanumeric value is F =>(F) 16
38
HEXADECIMAL CONVERSION
Hexadecimal to Decimal
Where,
• n is the number of digits, and
• r is the placement of the digit (from the right side starting from r = 0), and
• d is the decimal value of the corresponding digit.
39
Convert 6CF16 to decimal.
40
Convert 31.D216
Example
1. (3A7B)16 in to decimal
3 -> 0011
A -> 1010
7 -> 0111
B -> 1011
2. Combine the binary equivalents: 0011101001111011
42
(3A7B) = (0011101001111011)
Hexadecimal to Octal
We can convert a hexadecimal number to octal in two steps.
1-HEXADECIMAL TO BINARY
2-BINARY TO OCTAL
Example
Convert (3A)16 = (?)8
1-HEXADECIMAL TO BINARY
write 4 bit binary equivalent of each hexadecimal digit in
the same order.
43
2-BINARY TO OCTAL
Starting from the least significant bit, we partition the binary
number into groups of 3 bits and proceed to the left.
44
BINARY ARITMETIC OPERATIONS
• Basic arithmetic operations - addition, subtraction, multiplication, and division.
•Binary Addition
•Rules
Augend Addend sum carry
0 0 0 -
0 1 1 -
1 0 1 -
1 1 0 1
45
Add the binary numbers 11.10 and 01.11
Augend 11.10
Addend 01.11
Carry 11
11.10
+01.11
101.01
46
47
48
•Binary Subtraction
•Rules
Minuend Subtrahend Difference Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
49
Subtract the binary numbers 01.11 from 11.10
Minuend 11.10
Subtrahend 01.11
11.10
-01.11
1.11 => Difference
50
51
52
•Binary Multiplication
•Rules
53
Multiply Binary Number 1001 with 101
Multiplicand 1001
Multiplier 101
Þ 1001 X 101
1001
1001S
101101
S -> Shift
54
55
56
•Binary Division
•Rules
57
58
Divide binary number 11010 by 101
Divisor 101
Dividend 11010
Quotient 101
Remainder 1
59
INTEGER REPRESENTATION
61
SIGNED INTEGERS
1.Sign-Magnitude representation
In sign-magnitude representation:
integer.
There are two representations (0000 0000B and 1000 0000B) for the
number zero, which could lead to inefficiency and confusion.
Positive and negative integers need to be processed separately.
65
1'S COMPLEMENT REPRESENTATION:
MSB is the sign bit, with value of 0 representing positive integers and 1
representing negative integers.
The remaining n-1 bits represents the magnitude of the integer, as
follows:
positive integers, the absolute value of the integer is equal to "the
magnitude of the (n-1)-bit binary pattern".
negative integers, the absolute value of the integer is equal to "the
magnitude of the complement (inverse) of the (n-1)-bit binary pattern"
(hence called 1's complement). 66
67
the drawbacks are:
There are two representations (0000 0000B and 1111 1111B) for zero.
The positive integers and negative integers need to be processed
separately. 68
2'S COMPLEMENT REPRESENTATION
72
73
• Because of the fixed precision (i.e., fixed number of bits), an
n-bit 2's complement signed integer has a certain range.
• For example, for n=8, the range of 2's complement signed
integers is -128 to +127.
• During addition (and subtraction), it is important to check
whether the result exceeds this range, in other words,
whether overflow or underflow has occurred.
74
75
1's complement
The 1's complement of a number is found by changing all 1's to 0's and
all 0's to 1's.
76
2's complement
77
FLOATING-POINT NUMBER REPRESENTATION
The central processing unit (CPU) typically consists of an arithmetic
logic unit (ALU), floating point unit (FLU/FPU), registers, control unit,
and the cache memory.
The arithmetic logic unit performs integer arithmetic operations such
as addition, subtraction, and logic operations such as AND, OR, XOR,
etc.
Integers are whole numbers without fractional components. 1, 2, and
3 are integers, while 0.1, 2.2, and 3.0001 all have fractional
components are called floating point numbers. 78
The floating point unit performs floating point operations.
Floating point numbers have a sign, a mantissa, and an
exponent.
The Institute of Electrical and Electronics Engineers (IEEE)
developed a standard to represent floating point numbers,
referred to as IEEE 754.
This standard defines a format for both single (32-bit) and
double (64-bit) precision floating point numbers.
Decimal floating points are represented by ,
where M is the signed mantissa and E is the exponent. 79
A floating-point number is typically expressed in the scientific notation
82
Rule using 1s Complement(UNSIGNED)
Step 1: Given numbers must be in the form X-Y with same digits.
Extra 0 can be added at the beginning to make same digits.
Step 2: Calculate 1's complement of ‘Y’
Step 3: Add result of step 2 with ‘X’
Step 4: If there is extra bit, remove that extra bit and add on its
remaining bit.
If there is no extra bit, find 1's Complement of result in step
3 and add (-)ve sign. 83
Subtract (1010)2 from (1111)2 using 1’s complement method.
84
Example: Subtract (1010)2 from (1000)2 using 1’s
complement method.
85
2’s Complement - Subtraction
Rule using 2s Complement(UNSIGNED)
Step 1: Given numbers must be in the form X-Y with same digits.
Extra 0 can be added at the beginning to make same digits.
Step 2: Calculate 2’s complement of ‘Y’
Step 3: Add result of step 2 with ‘X’
Step 4: If there is extra bit, remove that and remaining bit will be the
answer.
If there is no extra bit, find 2’s Complement of result in step 3 and
add (-)ve sign. 86
Example: Subtract (1010)2 from (1111)2 using 2’s
complement method.
Solution:
Step-1: 2’s complement of (1010)2 is (0110)2.
Step-2: Add (0110)2 to (1111)2. This is shown below.
Step -3 & Step-4:
87
Subtract (1010)2 from (1000)2 using 2’s complement.
Solution:
Step-1: Find the 2’s complement of (1010)2. It is (0110)2.
Step-2: Add (0110)2 to (1000)2.
88
Binary Addition Using Signed Two’s Complement
89
90