Number System and Complements

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

INTRODUCTION

• A number system defines how a number can be


represented using distinct digits or symbols.

• A number can be represented differently in


different systems. For example, the two numbers
(2A)16 and (52)8 both refer to the same quantity,
(42)10, but their representations are different.

• Types of Number Systems:


1. Non-positional number systems
2. Positional number systems
NON-POSITIONAL NUMBER SYSTEMS

• Non-Positional Number System does not use digits


for the representation instead it use symbols for the
representation.

• A non-positional number system still uses a limited


number of symbols in which each symbol has a
value.
• The value of each symbol is fixed.

• Digit value is independent of its position.

• Difficulty to perform arithmetic with such a number


system
Roman numerals are a good example of a non-
positional number system. This number system has
a set of symbols S = {I, V, X, L, C, D, M}. The values
of each symbol are shown as:

To find the value of a number, we need to add


the value of symbols subject to specific rules .
POSITIONAL NUMBER SYSTEMS

In a positional number system, the position


a symbol occupies in the number determines
the value it represents. In this system, a
number represented as:

has the value of:

in which S is the set of symbols, b is the base


(or radix).
• In a Positional Number System there are
only a few symbols that represent different
values, depending on the position they
occupy in a number.

• The value of each digit in such a number is


determined by three considerations

• a. The digit itself


• b. The position of the digit in the number
• c. The base of the number system(where
base is defined as the total number of
digits available in the number system)
R based Number system
A number system has a base/ radix (R) associated with it.

Any positive integer, R, (R>1) can be chosen as the base


(or radix) of a number system.

If the base is R, then R digits are used [0,1,2,3,...,R-1].

For example, Decimal/Denary system (the most


common system in use today) the radix (base
number) is ten, because it uses the ten digits from
0 through 9.
R based Number system
A number with base r with form/shape as

is equal to

• For Example

(1234.5)10 = 1X103 + 2X102 + 3X103 + 4X104 + 5X10-1


Digital Number Systems
There are many numbering systems used in digital technology.

 Decimal - most familiar to us (base 10)


 Binary (base 2)
 Octal (base 8)
 Hexadecimal (base 16)
Decimal System
It is also called as base 10 (due to 10-symbols
representation)
It is a positional numeral system.
Example:
Given a decimal number of 1429
For digit 1 - one thousand (1 x 103)
digit 4 - four hundred (4 x 102)
digit 2 - twenty (2 x 101)
digit 9 - nine (9 x 100)
• What is the MSD (most significant digit, first nonzero digit
from the left) of 1429?
• What is the LSD (least significant digit, last nonzero digit from
the right) of 1429?
• For a whole number, the first digit to the left of the radix point
is the LSD.
Binary System
It is also called as base 2 (due to 2-symbols representation)
It is also a positional numeral system. However, the weight of
its bit is different than decimal.
Example

101012 = (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) x (1 x 20)


= 16 + 0 + 4 + 0 + 1
= 2110
Example:
 A switch has only 2 states - open or closed.
 Information stored in CD - holes are burnt form pits (non-
reflective) as ‘1’ or reflective areas as ‘0’.
 Diode - conducting or non-conducting.
Octal Number System
A positional number system.
Has total 8 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7).
The maximum value of a single digit is 7 (one less than the
value of the base
Each position of a digit represents a specific power of the base
(8)
 Since there are only 8 digits, 3 bits (23 = sufficient to
represent any octal number in binary)
Example
20578 = (2 x 83) + (0 x 82) + (5 x 81) + (7 x 80)
= 1024 + 0 + 40 + 7
= 107110
Hexadecimal Number System
A positional number system.
Has total 16 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B,
C, D, E, F).
The maximum value of a single digit is 15 (one less than the
value of the base)
Each position of a digit represents a specific power of the base
(16).
Since there are only 16 digits, 4 bits (24 = 16) are sufficient to
represent any hexadecimal number in binary
Example 1AF16
= (1 x 162) + (A x 161) + (F x 160)
= 1 x 256 + 10 x 16 + 15 x 1
= 256 + 160 + 15
= 43110
Why Hexadecimal and Octal Number System
 The octal or hexadecimal representation is more desirable
because it can be expressed more compactly with a third or a
quarter of the number of digits required for the equivalent
binary number.
 Thus, most computer manuals use either octal or
hexadecimal numbers to specify binary quantities.
 The choice between them is arbitrary, although hexadecimal
tends to win out, since it can represent a byte with two digit

Example Thus, the binary number 111111111111 has 12


digits and is expressed in octal as 7777 (4
digits) or in hexadecimal as FFF (3 digits)
Growth of Binary Number with Power of 2

n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo

3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega

6 26=64 30 230=1G Giga


7 27=128 40 240=1T Tera

14
Number Conversions - Decimal to Other Base System

• Step 1 − Divide the decimal number to be converted by the value


of the new base.
• Step 2 − Get the remainder from Step 1 as the rightmost digit
(least significant digit) of new base number.
• Step 3 − Divide the quotient of the previous divide by the new
base.
• Step 4 − Record the remainder from Step 3 as the next digit (to
the left) of the new base number.

Repeat Steps 3 and 4, getting remainders from right to left, until


the quotient becomes zero in Step 3.

The last remainder thus obtained will be the Most Significant Digit
(MSD) of the new base number.
Number Conversions - Decimal to Other Base System

• To convert fraction part, start with the fraction in the question


and multiply it by new base, keeping notice of the resulting
integer and fractional part.
• Continue multiplying by new base until you get a resulting
fractional part equal to zero.
• Then just write out the integer parts from the results of each
multiplication.

Consider, F = ( . a-1 a-2 ...a-m ) R

= a-1 * R-1 + a-2 * R-2+... a-m * R-m


Conversion of 2910 to Binary

Step Operatio Result Remainder


n
Step 1 29 / 2 14 1
Step 2 14 / 2 7 0
Step 3 7/2 3 1
Step 4 3/2 1 1
Step 5 1/2 0 1

Decimal Number − 2910 = Binary Number − 111012.


Conversion of 75.375 (decimal) to Binary:

Step Operatio Result Remainder


n
Step 1 75 / 2 37 1
Step 2 37 / 2 18 1
Step 3 18 / 2 9 0
Step 4 9/2 4 1
Step 5 4/2 2 0
Step 6 2/2 1 0

Decimal Number − 7510 = Binary Number − 10010112.


Step Fractio Fractio Remain Integer
n n X2 der
Fraction
Step 1 0.375 0.750 0.75 0
Step 2 0.75 1.50 0.50 1
Step 3 0.50 1.00 0.00 1

Decimal Number − 0.37510 = Binary Number − 0112.

So, Decimal Number − 75.37510 = Binary Number − 1001011.0112.


Conversion of 952 (decimal) to Octal:

Step Operatio Result Remainder


n
Step 1 952 / 8 119 0
Step 2 119 / 8 14 7
Step 3 14 / 8 1 6
Step 4 1/8 0 1

Hence, 95210 = 16708


Conversion of 2482 (decimal) to Hexadecimal:

Step Operatio Result Remainder


n
Step 1 2482 / 155 2
16
Step 2 155 / 16 9 11
Step 3 9 / 16 0 9

Hence, 248210 = 9B2 16


Other Base System to Decimal System

• Step 1 − Determine the column (positional) value of each digit (this


depends on the position of the digit and the base of the number
system).

• Step 2 − Multiply the obtained column values (in Step 1) by the


digits in the corresponding columns.

• Step 3 − Sum the products calculated in Step 2. The total is the


equivalent value in decimal.
Example 1

101112 = (1 x 24) + (0 x 23) + (1 x 22) + (1 x 21) x (1 x 20)


= 16 + 0 + 4 + 2 + 1
= 2310
Example 2
47068 = (4 x 83) + (7 x 82) + (0 x 81) + (6 x 80)
= 2048 + 448 + 0 + 6
= 250210
Example 3
1BF16 = (1 x 162) + (B x 161) + (F x 160)
= 1 x 256 + 11 x 16 + 15 x 1
= 256 + 176 + 15
= 44710
Other Base System to Non-Decimal System
• Step 1 − Convert the original number to a decimal number (base 10).
• Step 2 − Convert the decimal number so obtained to the new base
number.
Step 2: Convert 20910 to base 4
Example Remainders
4 209 1
5456 = ?4 52 0
13 1
3 3
Solution:
0
Step 1: Convert from base 6 to base 10
5456 = 5 x 62 + 4 x 61 + 5 x 60 Hence, 20910 = 31014
= 5 x 36 + 4 x 6 + 5 x 1 So, 5456 = 20910 = 31014
= 180 + 24 + 5
= 20910 Thus, 5456 = 31014
Shortcut Method for Converting a Binary Number to
its Equivalent Octal Number
Method
Step 1: Divide the digits into groups of three starting from the right
Step 2: Convert each group of three binary digits to one octal digit using
the method of binary to decimal conversion
•Example
• 11010102 = ?8
• Step 1: Divide the binary digits into groups of 3 starting from right
• 001 101 010
Step 2: Convert each group into one octal digit
0012 = 0 x 22 + 0 x 21 + 1 x 20 = 1
1012 =5
= 1 x 22 + 0 x 21 + 1 x 20
0102 =2
= 0 x 22 + 1 x 21 + 0 x 20
Hence, 11010102 = 1528
Shortcut Method for Converting a Octal Number to its
Equivalent Binary Number
• Write down the equivalent binary of each octal digit

Example - 5628 = ?2

Step 1: Convert each octal digit to 3 binary digits


58 = 1012, 68 = 1102, 28
= 0102

Step 2: Combine the binary groups


5628 = 101 110 010
5 6
Hence, 562 = 2
8
1011100102
Shortcut Method for Converting a Binary Number to its
Equivalent Hexadecimal Number
Method
Step 1: Divide the binary digits into groups of four starting from the right
Step 2: Combine each group of four binary digits to one hexadecimal digit
Example

1111012 = ?16
Step 1: Divide the binary digits into groups of four starting from the right
0011 1101
Step 2: Convert each group into a hexadecimal digit
00112 =0x 23 + 0 x 22 + 1 x 21 + 1 x 20 = 310
=316
11012 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 1310

= D16
Hence, 1111012 = 3D16
Shortcut Method for Converting a Hexadecimal Number to
its Equivalent Binary Number

• Write down the equivalent binary of each Hexadecimal digit

Example
2AB16 = ?2
Step 1: Convert each hexadecimal digit to a 4 digit binary
number
216 = 210
A16 = 1010 = 10102

B16 = 1110 = 10112


Step 2: Combine the binary
groups 2AB = 0010 1010 1011
16

2 A B

Hence, 2AB16 = 0010101010112


• Find r such that (121)r=(144)8

1448 = (1 x 82) + (4 x 81) + (4 x 80)


= 64 + 32 + 4
= 10010

and

121r = (1 x r2) + (2 x r1) + (1 x r 0)

= r2 + 2r + 1
to find r solve quadratic equation
r2 + 2r + 1 = 100
r +1= 10
r=9
1)

2) (2.3)4 + (1.2)4 = (Y)4 what is the value of Y?


Complements of r-base Number system
 There are two types of complements for each base-r system:
 Diminished radix complement.
The radix complement

Diminished Radix Complement - (r-1)’s Complement


 Given a number N in base r having n digits, the (r–1)’s complement of N
is defined as:
(rn –1) – N

• For Example for 6-digit decimal (base-10) numbers:


9’s complement is (rn – 1)–N = (106–1)–N = 999999–N

9’s complement of 546700 is 999999–546700 = 453299

It is clear from above example that (r-1)’s complement of any r-base number is
find out by subtracting each digit from (r-1)

31
Complements of r-base Number system
Example for 7-digit octal numbers:

7’s complement is (rn – 1) – N = (27–1)–N = 7777777–N


7’s complement of 5673512 is 7777777–5673512 = 2104265

 Example for 7-digit binary numbers:


 1’s complement is (rn – 1) – N = (27–1)–N = 1111111–N
 1’s complement of 1011000 is 1111111–1011000 = 0100111

 Observation:
 Subtraction from (rn – 1) will never require a borrow.
 Diminished radix complement can be computed digit-by-digit.
 For binary: 1 – 0 = 1 and 1 – 1 = 0.

32
Complements of r-base Number system
The Radix Complement - r’s Complement
The r's complement of an n-digit number N in base r is defined as
rn – N for N ≠ 0 and as 0 for N = 0.

Comparing with the (r  1) 's complement, we note that the r's


complement is obtained by adding 1 to the (r  1) 's complement,

since rn – N = [(rn  1) – N] + 1.

Alternatively r’s complement of any r-base number can be find out


by subtracting the fist non-zero LSB digit from r-base and then after
subtracting each digit from r-1, keeping all initial LSB zeros as it is.

The 10's complement of 246700 is 753300


 Example: Base-10

33
The 2's complement of 1101100 is 0010100
 Example: Base-2
Subtraction with Complements
The subtraction of two n-digit unsigned numbers M – N in
base r can be done as follows:

1. Add the minuend M to the r’s complement of the subtrahend N.


Mathematically, M+(rn –N) = M-N+ rn
2. If M≥N, the sum will produce an end carry rn, which can be
discarded; what is left is the result M-N.
3. If M < N, the sum does not produce an end carry and is equal
to rn – (N - M), which is the r’s complement of (N-M). To obtain
the answer in a familiar form, take the r’s complement of the
sum and place a negative sign in front

34
Subtraction with Complements
Example
Using 10's complement, subtract 72532 – 3250.

Example
Using 10's complement, subtract 3250 – 72532.

There is no end carry.

Therefore, the answer is – (10's complement of 30718) =  69282.


35
Subtraction with Complements
Example
Given the two binary numbers X = 1010100 and
Y = 1000011, perform the subtraction
(a) X – Y ; and (b) Y  X, by using 2's complement.

There is no end carry.


Therefore, the answer is Y – X
=  (2's complement of 1101111)
=  0010001.
36
Subtraction with Complements
Subtraction of unsigned numbers can also be done by
means of the (r  1)'s complement. Remember that the (r
 1) 's complement is one less then the r's complement.
Example
 Repeat previous Example, but this time using 1's complement.

There is no end carry,


Therefore, the answer is Y – X
=  (1's complement of 1101110)
37 =  0010001.
THANK YOU

You might also like