0% found this document useful (0 votes)
10 views22 pages

Chapter 2

The document discusses data representation in computer organization, focusing on various numbering systems such as binary, decimal, octal, and hexadecimal. It explains conversion methods between these systems, negative integer representations, and floating-point arithmetic. Additionally, it addresses character representation using ASCII and Unicode.

Uploaded by

Feyissa Boru
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)
10 views22 pages

Chapter 2

The document discusses data representation in computer organization, focusing on various numbering systems such as binary, decimal, octal, and hexadecimal. It explains conversion methods between these systems, negative integer representations, and floating-point arithmetic. Additionally, it addresses character representation using ASCII and Unicode.

Uploaded by

Feyissa Boru
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/ 22

04/23/2025 1

COMPUTER ORGANIZATION
&
ARCHITECTURE

CHAPTER TWO

Data Representation
04/23/2025 2

Numbering Systems
 Most modern computer systems do not represent numeric values using the
decimal system.
 Numbering system it uses is a specific radix (base 2).
 Radices that are power of 2 are widely used in digital systems.
 These radices include:
Binary (base 2),
Quaternary (base 4),
Octagonal (base 8),
Decimal (base 10) and
Hexagonal (base 16).
 The base 2 binary system is dominant in computer systems.
04/23/2025 3

The Decimal Number System


In everyday life we use a system based on decimal digits (0, 1, 2, 3, 4, 5,
6, 7, 8, 9) to represent numbers and refer to the system as the decimal
system. Example: the number 83 means, eight tens plus three: 83 = (8 *
10) + 3
The decimal system is said to have a base/radix of 10. This means that
each digit in the number is multiplied by 10 raised to a power
corresponding to that digit’s position.
The same principle holds for decimal fractions but negative powers of 10
are used. Example: the decimal fraction 0.256 stands for 2 tenths plus 5
hundredths plus 6 thousandths (2*10-1 + 5*10-2 + 6*10-3)
04/23/2025 4

The Binary Number System


In the decimal system, 10 different digits are used to represent
numbers with a base of 10 but in the binary system, we have only
two digits, 1 and 0.
Thus, the numbers in the binary system are represented to the
base 2.
In general, for the binary representation of
the value of Y is
Example: (1001.101)2 = (1*23 + 0*22 + 0*21 + 1*20 + 1*2-1 + 0*2-2

+ 1*2-3)
04/23/2025 5

Hexadecimal Number System


The hexadecimal number system use 16 different symbols.
The notation is called hexadecimal, and the 16 symbols are the hexadecimal
digits.
Hexadecimal notation is used for representing of integers, any sequence of
binary digits, whether they represent text, numbers, or some other type of data.
 The reasons for using hexadecimal notation are:
I. It is more compact than binary notation.
II. In most computers, binary data occupy some multiple of 4 bits, and
hence some multiple of a single hexadecimal digit.
III. It is extremely easy to convert between binary and hexadecimal.
Example: (110111100001)2 equivalent to (DE1)16
04/23/2025 6

Numbering System Conversion


Base R- to decimal conversion
 Binary (base 2): weights in powers-of-2.
Binary digits (bits): 0, 1.
 Octal (base 8): weights in powers -of-8.
Octal digits: 0, 1,2,3,4,5,6,7.
 Hexadecimal (base 16): weights in powers-of-16.
Hexadecimal digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Binary (base 2) to decimal .
(1101.101)2 = 1* 23 + 1* 22 + 1* 20 + 1* 2-1 + 1*2-3= 8 + 4
+ 1 + 0.5 + 0.125 = (13.625)10
Octal (base 8) to decimal
(572.6)8 = 5 * 82 + 7 * 81 + 2 * 80 + 6 * 8-1 = 320 + 56 +
16 + 0.75 = (392.75)10
04/23/2025 7

Hexadecimal (base 16) to decimal


(2A.8)16 = 2 * 161 + 10 * 160 + 8 * 16-1 = 32 + 10 + 0.5 = (42.5)10
Decimal-to-Binary Conversion
Step 1: Break the number in two parts: Whole number and fraction part.
Step 2: Repeated Division-by-2 Method (for whole numbers)
Step 3: Repeated Multiplication-by-2 Method (for fractions)

2 43

2 21 rem 1  LSB

2 10 rem 1 So, (43)10 = (101011)2

2 5 rem 0

2 2 rem 1

2 1 rem 0
04/23/2025 8

 To convert decimal fractions to binary, repeated


multiplication by 2 is used, until the fractional product
is 0 (or until the desired number of decimal places).
The carried digits, or carries, produce the answer, with
the first carry as the MSB, and the last as the LSB.
 E.g. (0.6875)10 = (0.1011)2
integer/coefficient fraction
0.6875 *2 = 1 + 0.375
0.375 *2 = 0 + 0.750
0.75 *2 = 1 + 0.500
0.5 *2 = 1 + 0.000

So, (0.1011)2
04/23/2025 9

Binary to Octal Conversion


 To convert Binary to Octal, make Partition of bits in groups of 3
 And directly convert each groups to octal numbers
Eg convert (10111011001 . 101110)2 to octal
Group bits into 3, (10 111 011 001 . 101 110)2 = (2731.56)8
 Conversion of octal to binary is the reverse of above
(2731.56)8 = (10 111 011 001 . 101 110)2
Binary to Hexadecimal Conversion
 To convert Binary to hexadecimal, make Partition of bits in groups
of 4
 And directly convert each groups to hexadecimal numbers
Eg convert (10111011001 . 10111000)2 to hexadecimal
Group bits into 4, (101 1101 1001 . 1011 1000)2 = (5D9.B8)16
 Conversion of hexadecimal to binary is the reverse of above
(5D9.B8)16 = (101 1101 1001 . 1011 1000)2
04/23/2025 10

Negative Integer Representation


There exist a number of methods for representation of negative integers.
These includes:
 the sign-magnitude
 the radix/base complement
Sign and Magnitude
According to this representation
The most significant bit (of the n bits used to represent the number) is used to
represent the sign of the number
If in the most significant bit position is “1”, it indicates a negative number
If “0” in the most significant bit position, it indicates a positive number.
04/23/2025 11

The remaining (n-1) bits are used to represent the magnitude of the number.
For example, the negative number (-18) is represented using 6 bits, base 2 in
the sign-magnitude format, as follows (110010),
while a (+18) is represented as (010010).
Although the sign-magnitude representation is complicated when performing
arithmetic operations.
 for example, the addition of the two numbers +18 (010010) and -19 (110011)
using the sign-magnitude representation.
Since the two numbers carry different signs, then the result should carry the
sign of the larger number in magnitude, in this case the (-19). The remaining 5-
bit numbers are subtracted (110011 - 010010) to produce (100001), that is, (-1).
04/23/2025 12

Radix Complement
According to this system:
 The positive number is represented the same way as in the sign-magnitude.
 But the negative number is represented using the b’s complement (b for base
numbers).
For example, the representation of the number (-19) using 2’s complement. In
this case, the number 19 is first represented as (010011). Then each digit is
complemented, hence the name radix complement to produce (101100).
Finally a “1” is added at the least significant bit position to result in (101101).
Example2: consider the 2’s complement representation of the number (+18).
Since the number is positive, then it is represented as (010010), the same as in
the sign-magnitude case.
04/23/2025 13

1’s and 2’s complement notations


1’s complement Representation
 In these notations, a positive number is represented
as it is (like an unsigned positive number)
 A negative number, however, is represented by
taking the complement of unsigned number
 1s complement of an unsigned number is obtained
by inverting all the bits of the number
 Examples: 1s complement of (00000001) 2 is
(11111110)1s
04/23/2025 14

Two’s Complement (2’s) Representation


 To represent a number in 2’s complement, we perform the following two
steps.
1. Perform the Boolean complement of each bit (including the sign bit);
2. Add 1 to the least significant bit (i.e. -A= A’+ 1)
Example: Consider the representation of (-22) using 2’s complement.
Solution: 22=00010110
11101001 1’s complement
+ 1 2’s complement
11101010 = (-22)
The main advantage of the 2’s complement representation:
I. is that no special treatment is needed for the sign of the numbers.
II. If carry coming out of the most significant bit while performing
arithmetic operations is ignored without affecting the correctness of the
result (i.e. no effect in result!)
04/23/2025 15

Two’s Complement Arithmetic operations


A. Addition:
 Addition of two n-bit numbers in 2’s complement can be performed using an
n-bit adder.
 Any carry-out bit can be ignored without affecting the correctness of the
results, as long as the results of the addition is in the range -2 n-1 to 2n-1 -1

Example: (-7 )+ (+4)= -3 that is, (1001 )+ (0100) = 1101, a (-3) in 2’s
complement.
(+6)+(+7)=+13, that is, 0111 + (0110) = 1101, a wrong result. This is
because the result exceeds the largest value (+7).
Example2: (-7)+(-4)=-11 , that is, 1001+ (1100) = 0101, a wrong result. This is
because the result is less than the smallest value (-4). Notice that the original
numbers are negative while the result is positive.
04/23/2025 16

Floating-point representation and arithmetic


Floating-Point Representation:
A floating-point (FP) number can be represented in the following form:,
where m, called the mantissa, represents the fraction part of the number and is
normally represented as a signed binary fraction, e represents the exponent, and b
represents the base (radix) of the exponent.
Fig 2.1 Representation of a floating-point number

Figure 2.1 is a representation of a floating-point number having m = 23 bits, e= 8


bits, and S (sign bit)= 1 bit.
If the value stored in S is 0, the number is positive and if the value stored in S is
1, the number is negative.
04/23/2025 17

Floating-Point Arithmetic Addition/Subtraction


The difficulty in adding two FP numbers stems from the fact that they may
have different exponents.
Therefore, before adding two FP numbers, their exponents must be equalized,
that is, the mantissa of the number that has smaller magnitude of exponent must
be aligned.
Steps Required to Add/Subtract Two Floating-Point Numbers
1. Compare the magnitude of the two exponents and make suitable
alignment to the number with the smaller magnitude of exponent.
2. Perform the addition/subtraction.
3. Perform normalization by shifting the resulting mantissa and adjusting
the
resulting exponent.
04/23/2025 18

Example: consider adding the two FP numbers 1.1100*24 and 1.1000*22


1. Alignment: 1.1000 * 22 has to be aligned to 0.0110 * 24
2. Addition: Add the two numbers to get 10.0010 * 24.
3. Normalization: The final normalized result is 0.1000 * 2 6 (assuming 4 bits
are allowed after the radix point).
Multiplication:
Multiplication of a pair of FP numbers X = m x * 2a and Y = my * 2b is

represented as X * Y= (mx my) * 2a+b.


A general algorithm for multiplication of FP numbers consists of three basic
steps. These are:
1. Compute the exponent of the product by adding the exponents together.
2. Multiply the two mantissas.
3. Normalize and round the final product.
04/23/2025 19

Example: consider multiply the two FP numbers X=1.000*2 -2 and Y=-1.010*2-1

Solution:

1. add exponents: -2+(-1) =-3


2. multiply the mantissas: 1.000*-1.010=-1.01000
Then the product is: -1.0100*2-3

Division:
 Division of a pair of FP numbers X=mx * 2a and Y= my * 2b is represented as

X/Y= (mx /my)* 2a-b.


A general algorithm for division of FP numbers consists of three basic steps:
1. Compute the exponent of the result by subtracting the exponents.
2. Divide the mantissa and determine the sign of the result.
04/23/2025 20

EXAMPLE: consider the division of two FP numbers X=1.000*2-2 and


Y= -1.0100*2-1
1. Subtract exponents: -2 - (-1)=-1.
2. Divide the mantissas: 1.0000/-1.0100= -0.1101.
3. The result is -0.1101* 2-1.

Representation of non numeric data(character codes and graphical


symbols)
Character data is probably the most common data type encountered besides
integer Values.
the different characters includes: non printable characters called the control
characters, various punctuation symbols, special characters, numeric digits; upper
case and lower case alphabetic symbols etc.
04/23/2025 21

So we use the ASCII to represent for those different characters in modern


programs.
ASCII use 7-bits for character representation and it can only represent up to 128
separate character codes/ unique code.
But ASCII code can not represent for characters that have more than 128 bit
lengths
So in modern computer system it is being replaced by Unicode which is designed
to cope with many more character sets.
Unicode uses 16-bits.
04/23/2025 22

Table 2.1 The ASCII codes

You might also like