0% found this document useful (0 votes)
47 views41 pages

Number Systems in Computer Architecture

The document discusses number systems used in computers including binary, octal, decimal, and hexadecimal. It provides details on converting between these number systems, describing the process of grouping bits or digits and determining the equivalent value in another base. Converting between two bases can involve first converting to an intermediate base like decimal or binary.

Uploaded by

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

Number Systems in Computer Architecture

The document discusses number systems used in computers including binary, octal, decimal, and hexadecimal. It provides details on converting between these number systems, describing the process of grouping bits or digits and determining the equivalent value in another base. Converting between two bases can involve first converting to an intermediate base like decimal or binary.

Uploaded by

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

MTU

School of computing and informatics


Department of computer science
Computer Organization And Architecture
Lecture -2

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 1


Chapter-Two
Number Systems
1.1 Introduction
A bit is the most basic unit of information in a computer.
 It is a state of “on” or “off” in a digital circuit.
 Sometimes these states are “high” or “low” voltage instead of “on” or “off..”
A byte is a group of eight bits.
 A byte is the smallest possible addressable unit of computer storage.
 The term, “addressable,” means that a particular byte can be retrieved
according to its location in memory.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 2


Cont…
A word is a contiguous group of bytes.
 Words can be any number of bits or bytes.
 Word sizes of 16, 32, or 64 bits are most common.
 In a word-addressable system, a word is the smallest addressable unit of
storage.
A group of four bits is called a nibble (or nybble).
 Bytes, therefore, consist of two nibbles: a “high-order nibble,” and a “low-
order” nibble.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 3


Cont…
Basically, there are two types of number systems.
Non-positional number system: The value of a symbol (digit) in a number
does not depend on the position of the digit in number.
Positional number system: The value of a symbol in the number is determined
by its position, the symbol and the base of the number system.
1. Decimal number system or the base 10 number system
Is the number system we use in our day-to-day life. The decimal number system
has 10 different symbols identified as 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 4


Cont…
2. Binary number system or base 2 number system
Has two digits 0 and 1.
The two digits of the binary number system correspond to the two distinct states
of the digital electronics.
Data Representation
Data in computers is represented in binary form.
The represented data can be number, text, movie, color (picture), sound, or
anything else.
We enter data into a computer using letters, digits & special symbols.
But inside the computer, there is no color, letter, digit or any other character
inside the computer system unit.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 5


Cont…
Computers understand and respond to only the flow of electrical charge.
This shows that the overall structure of computers work only in binary conditions (the
semiconductors are conducting or not conducting, a switch is closed or opened, a
magnetic spot is magnetized or demagnetized).
Hence, data must be represented in the form of binary code that has a corresponding
electrical signal.
The form of binary data representation system we are seeking is similar to the binary
number system in mathematics.
The number systems (bases) we will discuss are: decimal, binary, octal, and
hexadecimal.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 6


Cont…
Data representation using the binary number system results in a large string of 0s and 1s.
This makes the represented data large and difficult to read.
 For the sake of writing the binary strings in a short hand form and make them readable, the octal
and the hexadecimal number systems are used.

3. Octal number system or base 8 number system


Has 8 different symbols: 0, 1, 2, 3, 4,5, 6, and 7.

4. Hexadecimal number system or base 16 number system

Has 16 different symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.


It is used to write binary numbers in short form.
Memory addresses and MAC addresses are usually written in hex.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 7


2.1.1 Converting from one base to another

I. Conversion from Decimal to Base m


Step 1: Divide the given decimal number by m (the desired base). The result will
have a quotient and a remainder.
Step 2: Repeat step 1 until the quotient becomes 0, the quotient is 0 whenever the
number < m.
Step 3: Collect and arrange the remainders in such a way that the first remainder is
the least significant digit and the last remainder is the most significant digit.
Example: Convert the following decimal number 47 into binary, octal, and
hexadecimal.
A. Conversion to binary
In order to convert the given decimal numbers into binary (base 2), they are
divided by 2.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 8


Cont…

Hence the result is 1011112.

B. Conversion to octal: Here the numbers are divided by 8 because the required
base is octal (base 8).

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 9


Cont…
C. Conversion to hexadecimal: Since the conversion now is into hexadecimal
(base 16) the given decimal numbers are divided by 16.

The hexadecimal equivalent for the decimal 15 is F and that of 2 is 2. Therefore,


47 = 2F16

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 10


Cont…
II. Conversion from Base m to Decimal
Step 1: Multiply each digit by its positional value.
Step 2: Calculate the sum of the products you get in step 1.
Example 1: Convert the binary number 110001 and 1011.1101 into decimal.
a.1100012 = (1 × 25) + (1 × 24) + (0 × 23) + (0 × 22) + (0 × 21) + (1 × 20) = (1 × 32) + (1 × 16)
+ (0 × 8) + (0 × 4) + (0 × 2) + (1 × 1) = 32 + 16 + 0 + 0 + 0 + 1 = 49

Therefore, 1100012 = 49.

b. 1011.11012 =(1 x 23) + ( 0 x 22) + (1 x 21) x (1 x 20) + ( 1 x 2-1) + (1 x 2-2 ) + (0 x 2-3) (+


1 x 2-4) = (1x 8) + (0 x 4) + (1 x 2) + (1 x1) + (1 x ½) + (1 x ¼) + (0 x1/8) + (1 x 1/16) = 8
+ 0 + 2
+ 1+ ½ + ¼ + 0 + 1/16 = 11 + 13/16 =11.8

There fore, 1011.11012 = 11.8.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 11


Cont…
Example 2: Convert the octal number 22 into decimal.
228 = (2 × 81) + (2 × 80) = (2 × 8) + (2 × 1) = 16 + 2 = 18

Therefore, 228 = 18

Example 3: Convert the hexadecimal number D1 into decimal.


D116 = (13 × 161) + (1 × 160)

Therefore, D116 = 209

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 12


Cont…
III. Conversion from Binary to Octal
It is possible to use decimal number system as an intermediate base to convert
from any base to any other base.
However, for conversion from binary to octal or vice versa, there is a very simple
method.
Step 1: Group the binary digits (bits) starting from the rightmost dig into 3 bits. If
the remaining bits at the leftmost position are fewer than 3, add 0s at the front.
Step 2: For each 3-bit binary string, find the corresponding octal number.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 13


Cont…
Example: Convert the binary numbers 110011 and 1101111 to octal.

The bits are grouped in three with the equivalent octal digit given below the
three bit group. Thus, 1100112 = 638

The result is 11011112 = 1578.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 14


Cont…
IV. Conversion from Octal to Binary
Step 1: For each octal digit, find the equivalent three digit binary number.
Step 2: If there are leading 0s for the binary equivalent of the leftmost octal digit,
remove them.
Example: Find the binary equivalent for the octal numbers 73 and 160.

Therefore, 738 = 1110112 Thus, 1608 = 11100002

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 15


Cont…
From Binary to Hexadecimal
One possible way to convert a binary number to hexadecimal, is first to convert
the binary number to decimal and then from decimal to hex.
The simple steps states are stated below.
Step 1: Starting from the rightmost bit, group the bits in 4. If the remaining bits
at the leftmost position are fewer than 4, add 0s at the front.
Step 2: For each 4-bit group, find the corresponding hexadecimal number.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 16


Cont…

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 17


Cont…
VI. Conversion from Hexadecimal to Binary
Step 1: For each hexadecimal digit, find the equivalent four digit binary number.
Step 2: If there are leading 0s for the binary equivalent of the leftmost hexadecimal
digit, remove them.
Example: Find the binary equivalents for the hexadecimal numbers 1C and 823.

Thus, 1C16 = 111002


Hence, 82316 = 1000001000112.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 18


Cont…
VII. Conversion from Octal to Hexadecimal of Vice Versa
The decimal number system can be used as an intermediate conversion base.
Second alternative is using the binary number system as an intermediate base.
Step 1: Convert the given number into binary.
Step 2: Convert the binary number you got in step 1 into the required base.
Example : Convert the octal number 647 to hexadecimal.

Therefore, 6478 = 1A716

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 19


Cont…
Example 2: Find the octal equivalent for the hexadecimal number 3D5

Therefore, 3D516 = 17258

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 20


If the numbers we want to represent are only positive (unsigned) integers, the
solution is straightforward;
2.2RepresentationofIntegers(FixedpointRepresentation)

Simply represent the unsigned integer with its binary value. For example, 34 is
represented as 00100010 in 8 bits.
Signed integer representations are sign magnitude, 1’s complement, and 2’s
complement.
2.2.1 Sign-Magnitude Representation
In mathematics, positive integers are indicated by a preceding + sign (although
usually it is avoided) a preceding – sign identify the integer as a negative
number.
In computers, there is no place for a + or a – sign; there are only 0s and 1s.
05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 21
Cont…
A similar way of representing + and – signs is to treat the most
significant bit as a sign bit the remaining bits are used to represent the
magnitude of the integer.
By convention a 0 on the sign bit indicates the integer is positive and a 1
indicates the integer is a negative.
As example, the sign-magnitude representation of 79 and -79 in 8 bits are
01001111 and11001111 respectively.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 22


2.2.2 One’s Complement Integer Representation
Every number system has two complement systems. For a given base n the
complements are n’s complement and (n-1)’s complement.
Thus, in decimal numbers system (base 10), the complement systems are 10’s
complement and 9’s complement.
Similarly, in binary number system, the complements are 2’s complement and 1’s
complement.
Using complements in binary number systems makes subtraction and logical negation
very simple.
Furthermore, using complements makes arithmetic operations simple.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 23


Cont…
The one’s complement of a binary integer is found by inverting all 0s to 1s and
all 1s to 0s.
In one’s complement integer representation, the negative of an integer is
represented by its complement.
For example, the one’s complement representation of 16 and -16 in 8 bits are
00010000 and 11101111 respectively.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 24


2.2.3 Two’s Complement Integer Representation
The two’s complement of an integer is found by adding 1 to its one’s
complement.
As a reminder, in binary arithmetic, 0+1 = 1 and 1+1 = 0 with a carry of 1 to the
next higher significant bit.
A shortcut method to find the two’s complement of a number is to keep all the
bits up to and including the first 1 from the right and invert all the others.
Example, two’s complement representation of 19 and -19 in 8 bits are 00010011
and 11101101 respectively.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 25


2.3 Floating Point representation
Floating Point representation of a number has two parts.
The first part represents a signed, fixed-point number called the mantissa.
The second part designates the position of the decimal (or binary) point and is called
the exponent.
 Floating point is always represented as follows:
m x re where, m (mantissa) r(radix) and e(exponent)

For example, the decimal, +6132.789.

Fraction Exponent S cien tific N o ta tion (flo atin g p oin t)

e.g +0.6132789 +04 +0.6132789 x10 +4

Only the mantissa m and the exponent e are physically represented in the register (including their signs).

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 26


2.3 Floating Point representation
Floating Point representation of a number has two parts.
The first part represents a signed, fixed-point number called the mantissa.
The second part designates the position of the decimal (or binary) point and is called the
exponent.
 In order not to waste bits, the representation will normalize all the numbers. For example,
0.000123 wastes three zeroes on the left before non-zero digits.
 These zeroes have no meaning except to indicate the position of the Decimal point.
 Normalizing this number result in .123x10-3 .123 is the normalized mantissa; -3 is the
exponent.
 We have normalized this by eliminating all the meaningless zeroes to the left of the first non-
zero digit and by adjusting the exponent.
05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 27
Cont…
 The general form of floating point representation is ±Mx10 ±E where M is the
mantissa, and E is the exponent.
 It can be seen that a normalized number is characterized by a mantissa less than 1
and greater than or equal to 1 all cases when the number is not zero.
 To represent floating numbers in the computer system it should be normalized after
converting to binary number representation system.
 Ex2 111.01 is normalized as .11101x2 3 . The mantissa is 11101. The exponent is 3.
 The general structure of floating point representation in binary representation is
Sign /Exponent/ Mantissa (significant)
 In representing a number in floating point we use 1 bit for sing, some bits for
exponent and the remaining bit for mantissa.
05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 28
Cont…
 In floating point representation the exponent is represented by a biased exponent
Characteristics.
Biased exponent = true exponent + excess
Excess is 2n-1 where n is the number of bits reserved for the exponent.
Example1: Represent –236.375 in floating point using 7 bit for exponent and 16
bit for mantissa. First we have to change to normalized binary
i. e 236 = 11101100 0.375= 0.011
236.375 = 11101100.011 = 0.11101100011x28
true exponent = 8 and n = 7 (number of bit which is reserve to represent the
exponent with binary)
05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 29
Cont…
Excess is 2n-1 = 27-1 = 26 = 64
Biased exponent = 8+26 = 8+64 = 72 = (100 1000)2
Therefore –236.375 is represented as 1 1001000 1110110001100000
1 is the sign bit which indicates negative number
1001000 is the exponent
1110110001100000 is the mantissa.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 30


Cont…
Therefore to represent a floating number
First convert it to binary number system

Then normalized the binary number

Find the biased exponent by using the formula

Then change the biased exponent to binary

After all put together the number in the appropriate structure i.e.
sign/exponent/mantissa

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 31


2.4 Coding method
 Encoding System:- A piece of text in any language is a sequence of symbols
which are used to represent an idea in that language.
 For example, the English language uses 26 symbols (A, B, C... Z) to represent
uppercase letters, 26 symbols (a, b, c, ..., z) to represent lowercase letters, 9
symbols (0, 1, 2, ..., 9) to represent numeric characters and symbols like (., ?, :,
; ..., !) and other symbols such as the blank, the new line, and the tab used for
text alignment and readability.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 32


Cont…
 Different sets of bit patterns are designed to represent each symbols.
 In a character representation, a single character should be represented the given
number of bits of that coding scheme.
 The most commonly used coding to represent characters are:
2.4.1 Binary Coded Decimal (BCD)
This is the simplest coding scheme.
Originally, BCD coding is used four bits to represent each digit of the decimal
number into its binary equivalent rather than converting the entire decimal value
into a pure binary form.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 33


Cont…
Example: The code of the digit 1 is 0001.The code of the digit 4 is 0100. The code of
the digit 43 is 01000011
Note that each decimal digit is independently converted to a 4 bit binary number.
However, 4 bits are insufficient to represent the various characters used by a computer
system.
Instead of using 4 bits with only 16 possible characters, computer designers used
commonly 6 bits to represent characters in BCD.
 In the 6 bit BCD code the 4 BCD numeric place positions are retained but additional
zone positions are added.
With 6 bit, it is possible to represent 64 (26) different characters. This is a sufficient
number to code the decimal digits (10), alphabetic letters(26), and other special
characters (28).
05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 34
Cont…
 Example: Represent F in BCD.
 Solution: To represent F you have to ask question like where is F(position 6 for instance)? In
which range is it found? It is in the range A -I.
 So, the zone bits are determined as11. F is the sixth letter if you count starting from A.
 So, it will be represented by the decimal form of the digit which is 110 (or 0110 using 4 digits).
 Finally, the representation of F in BCD is 110110.
 Example: show the binary digits used to record the word BASE in 6 bit BCD code.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 35


2.4.2 EBCDIC (Extended Binary Coded Decimal Interchange Code)
 To make the number of characters represented by BCD more, 2 bits are added to the 6 bits
(totally 8 bits).
 This makes the improved BCD capable of representing 2 8 (256) characters.
 And this coding scheme is called Extended Binary Decimal Interchange Code (EBCDIC).
 EBCDIC is developed by IMB; it is an 8 bits pattern. The only difference between BCD and
EBCDIC is their zone bits.
 In EBCDIC, upper case letters, lower case letters, digits and other printable or non -
Printable characters are included.
 The limitation of EBCDIC is that, it is not used in any computer other than IBM machines.
 Unlike BCD, EBCDIC uses 4 zone bits and the following table shows you the equivalent
zone bits of EBCDIC to the BCD zone bits.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 36


Cont…
BCD EBCDIC Letters/ digits ASCII - 7 ASCII - 8 Letters/ digits
(zone bit) (zone bit) (represented) (zone bit) (zone bit) (represented)
11 1100 A –I
100 0100 A –O
10 1101 J –R
01 1110 S –Z 101 0101 P –Z
00 1111 0 –9
011 0011 0 –9
0110 a –i

Table 2.1 the conventional zone bits of BCD ,EBCDIC ,ASCII coding scheme

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 37


2.4.3 ASCII (American Standard Code for Information Interchange)
The other popular schemes are ASCII -7 and ASCII-8.
ASCII -8 is an extended version of ASCII-7.
Generally, ASCII-7 code was designed as a standard code for ISO (International
Organization for Standardization).
It is a 7-bit code and as a result representing 2 7(128) characters. From the 7-bits,
3-bits are used as zone bits and the other four bits represent the actual data.
ASCII is a little bit different from the BCD and EBCDIC because in ASCII
alphabetical letters are divided into two sections, not three.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 38


Cont…
Note in addition to the four bits that represent the actual data, additional two
bits are used as zone bits.
These bits are used to distinguish the actual data represented. Observe the
following example: In 6 Bit BCD representation, 0001 is used to represent three
characters, letter A, letter J Or digit 1.
How can you distinguish the character represented by 0001? By the zone bits.
The zone bits of the three characters are different. According to the above zone
bits, The digit 1 is represented as 000001. The letter A is represented as 110001.
The letter J is represented as 100001.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 39


Cont…
 Example 26: Represent the letter A in ASCII.
 Solution: Since A is in the range A_O and therefore the zone bits used must be
0100.So, the representation of letter A in ASCII will be 1000001.
ASCII-8:
 ASCII -8 is an extended version of ASCII, which uses 8 bits rather than 7 bits.
 ASCII-8 can represent 28(256) possible characters.
 The difference between ASCII & ASCII _ 8 is that only on their zone bits.
ASCII _ uses 4 bits as a zone bit.

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 40


END OF CHAPTER -TWO

05/11/2024 COMPUTER ORGANIZATION AND ARCHITECTURE SET BY GIZACHEW B. MTU DEPARTMENT OF CS 41

You might also like