0% found this document useful (0 votes)
22 views

Chapter 3

The document discusses data representation and number systems used in computers. It explains how computers use bits and bytes to represent different data types. It also describes binary, octal, decimal, and hexadecimal number systems and how to convert between them.

Uploaded by

Ali Hussen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Chapter 3

The document discusses data representation and number systems used in computers. It explains how computers use bits and bytes to represent different data types. It also describes binary, octal, decimal, and hexadecimal number systems and how to convert between them.

Uploaded by

Ali Hussen
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Computer Applications in Management

CHAPTER THREE

DATA REPRESENTATION AND NUMBER SYSTEMS

As all of you know a computer is a data processing machine, so we have to


understand the nature of data. Data can be found in different forms like as a
number, text, images audio & video.
Data inside the computer

How computers handle all these data types?

To handle & represent different data types, a computer uses universal


uniform representations of data is known as Bit Patterns. Bit pattern is a
sequence or strings of bits that is used to represent different data types.
Bit (Binary Digit)

Bit is the smallest unit of data that can be stored in a computer. It is a single bit
that can be stored in a computer. In other words, it is a single bit that can
represent two values; either 0 or 1.
Nibble

A nibble is a collection of bits on a 4-bit boundary. It wouldn't be a particularly


interesting data structure except for two items: BCD (binary coded decimal)
numbers and hexadecimal (base 16) numbers. It takes four bits to represent a
single BCD or hexadecimal digit.
Byte:

Without question, the most important data structure used by the most
microprocessor is the byte. A byte consists of eight bits and is the smallest
addressable datum (data item) in the microprocessor. It is the most important
data structure & is used by most microcomputer.
The bits in a byte are numbered from bit zero (b0) through seven (b7) as follows:

b7 b6 b5 b4 b3 b2 b1 b0

Werabe University Institute of Technology Page 1


Computer Applications in Management

Byte also contains exactly two nibbles. Since a byte contains eight bits, it can
^
represent 2 8, or A 256, different values. Generally, we'll use a byte to represent:

1. Unsigned numeric values in the range 0 - 255


2. signed numbers in the range -128 - +127
3. ASCII character codes
4. Other special data types requiring no more than 256 different values.
Many data types have fewer than 256 items so eight bits is usually sufficient
The Word: a word is a group of bits greater than or equal to 8 bits. There is no
fixed size for a word length. It depends on from computer to computer. Most
microprocessors & minicomputers are normally byte oriented with word length 8
bits, 16 bits 32 bits & 64 bits.
Number system
A number system defines a set of values used to represent quantity. Today the
most common number system in use is Arabic system. The number systems can
be categorized in to two broad categories: Positional number systems & Non-
positional number systems.
Non-Positional number systems: - is a method of counting on fingers. It was very
difficult to perform arithmetic with such a number system, as it had no symbol
for zero.
Positional number systems: - the value of each digit in a number is defined not
only by the symbol but also by the symbol’s position. They have a base or radix.
➢ Base (or radix): - tells the number of symbols used in the system. Modern
computers use the radix 2 because they recognize only two symbols, which are
represented in digital circuits as 0s and 1s.
The base of a number system is indicated by a subscript (decimal number) and
this will be followed by the value of the number.
For example (7592) 10 is of base 10 number system.
(1010) 2 is of base 2 number system.
Note: For a computer, everything is a number whether it may be numbers,
alphabets, punctuation marks etc.

Werabe University Institute of Technology Page 2


Computer Applications in Management

Eventually, the number systems that can are generally used by the computers
are:
• Decimal system
• Binary system
• Octal system
• Hexadecimal system

Number
Radix value Set of Digits Example
system
Decimal r = 10 (0,1,2,3,4,5,6,7,8,9) (25)10
Binary r=2 (0,1) (11001)2
Octal r=8 (0,1,2,3,4,5,6,7) (31)8
(0,1,2,3,4,5,6,7,8,9,A,
Hexadecimal r = 16 (1A)16
B,C,D,E,F)
1. Decimal Number system
▪ It is the primary number system used. Derived from the Latin word ‘Decimal’,
which means ten.
▪ Starting at the decimal point and moving to the left, each position is represented
by the base value raised to a power. 103 102 101 100
▪ Moving to the right of the decimal is just like moving to the left except that we will
need to place a minus sign in front of each power. . 10-1 10-2 10-3
Eg 9735 = (9x103) + (7x102) + (3x101) + (5x100)
2. Binary Number System
▪ Computers do not use the ten digits of the decimal system for counting and
arithmetic. Their CPU and Memory are made up of millions of tiny switches that
can be either in the ON or OFF states.
▪ The number system with only two digits (0 & 1) is called Binary number system.
The place value of the binary number system is based on the number two. In the
binary number system with base 2, the weight of n th bit of the number from Right
Hand Side (RHS) is nth bit x 2n-1

Werabe University Institute of Technology Page 3


Computer Applications in Management

3. Octal Number System


▪ It is a base 8 system. It uses powers of 8 to determine the digit of numbers
position.
Binary octal comparison
Octal to Binary Binary to Octal
2 3 5 010 011 101
010 011 101 2 3 5

Binary-Decimal-Octal Comparison

Binary Decimal Number Octal Number


Number
000 0 0 (0 x 80)
001 1 1 (1 x 80)
010 2 2 (2 x 80)
011 3 3 (3 x 80)
100 4 4 (4 x 80)
101 5 5 (5 x 80)
110 6 6 (6 x 80)
111 7 7 (7 x 80)
1000 8 10 (1 x 81 + 0 x 80)
1001 9 11 (1 x 81 + 1 x 80)
1010 10 12 (1 x 81 + 1 x 80)

Werabe University Institute of Technology Page 4


Computer Applications in Management

4. Hexadecimal Number System

 Hexadecimal number system has the base (radix) 16. Each


hexadecimal number represents a power of 16. To represent the
decimal numbers, this system uses 0-9 numbers and A to F
characters to represent 10 to 15, respectively.
Decimal-Hexadecimal-Binary-Octal Comparison

Decima Hex Binary Octal


l
0 0 0000 0
1 1 0001 1
2 2 0010 2
3 3 0011 3
4 4 0100 4
5 5 0101 5
6 6 0110 6
7 7 0111 7
8 8 1000 10
9 9 1001 11
10 A 1010 12
11 B 1011 13
12 C 1100 14
13 D 1101 15
14 E 1110 16
15 F 1111 17

Conversion between Number Systems


1. Conversion of Decimal to Binary:
Follow the following steps to convert decimals in to binary.
1. Begin by dividing the decimal number by 2 (the base of binary
number).
2. Note the remainder separately as the right most digit of the binary
equivalent.
3. Continually repeat the process of dividing by 2 until the quotient
is zero.

Werabe University Institute of Technology Page 5


Computer Applications in Management

4. Finally, when no more division can occur, write down the


remainders in reverse order (last remainder written first).
Eg. Determine the binary equivalent of (36) 10

2 36 Remainder
Least Significant Bit (LSB)
2 18 0
2 9 0
2 4 1
2 2 0
2 1 0
0 1 Most Significant Bit (MSB)

Taking the remainders in reverse order, we have 100100. Thus (36) 10 =


(100100) 2.
2. Conversion of Binary to Decimal: In this case, each digit of the
binary number is multiplied by its weighted position and each of the
weighted values is added together to get the decimal number.
Eg determine the decimal equivalent of (11010) 2
(11010) 2 = (1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (0 x 20)
= 16 + 8 + 0 + 2 + 0
= (26) 10
3. Conversion of Binary fractions to Decimal: here we use the negative
exponents, to denote the negative powers of two.
Eg. Determine the decimal equivalent of (0.01101) 2
(0.01101) 2 = (0 x 2-1) + (1 x 2-2) + (1 x 2-3) + (0 x 2-4) + (1 x 2-5)
=0 + ¼ + 1/8 + 0 + 1/32
=0 + 0.25 + 0.125 + 0 + 0.03125
= (0.40625) 10
4. Conversion of Decimal to Octal: Here the same procedure is adopted as
in decimal to binary conversion but the decimal number is divided by 8
(the base of the octal system).

Werabe University Institute of Technology Page 6


Computer Applications in Management

Eg. Determine the octal equivalent of (359) 10

8 359 Remainder
8 44 Least Significant Bit (LSB)
7 8 5
4 8 0
5 Most Significant Bit (MSB)

So (359) 10 = (547)8

5. Conversion of Decimal fraction to Octal fractions: The steps we have


to follow in this case
are:-
1. Multiply the decimal fraction by 8 (the base of the octal system).
2. If the whole number is generated, record the whole number, otherwise
place 0.
3. Repeat the above 1st and 2nd steps with the decimal fractions until it
becomes.
4. Finally, when no more multiplication can occur, write down the
remainders in the downward direction.
5. In this whole conversion, the first carry produced is the MSB while the
last carry is the LSB.

Eg. Determine the octal equivalent of (0.3125) 10.


0.3125 x 8 = 2.5 2
0.5 x 8 =4.0 4
So, (0.3125) 10 = (0.24) 8
Note: In some circumstances of changing the decimal fraction to octal
fractions the conversion may not end. In such cases you have to take the
approximate of 8 bits.
6. Conversion of octal to Decimal: Here each digit of octal number is
multiplied by its weighted position, and each of the weighted values are
added together to get the decimal number.
Eg. Determine the decimal equivalent of (456)8.

Werabe University Institute of Technology Page 7


Computer Applications in Management

(456) 8 = (4 x 82) + (5 x 81) + (6 x 80)


= 256 + 40 + 6
= (302) 10
7. Conversion of Octal fractions to Decimal fractions : Steps followed here
are:
1 Write the weight value of each bit of the octal fractional number.
2 Multiply the weighted position with the respective bit of the octal
fractional number.
3 Add all the weighted values to get the decimal number.
Eg. Determine the decimal equivalent of (237.04) 8.
(237.04) 8 = (2 x 82) + (3 x 81) + (7 x 80) + (0 x 8-1) + (4 x 8-2)
= (2 x 64) + (3 x 8) + (7 x 1) + (0) + (4 x 1/64)
= 128 + 24 + 7 + 0 + 0.0625
= (159.0625) 10
8. Conversion of Binary to Octal: steps that are followed here are:
1 Break the binary number in to 3-bit sections starting from the LSB to
the MSB.
2 Convert the 3-bit binary number to its octal equivalent.
For whole numbers, it may be necessary to add a zero as the MSB in order
to complete a grouping of three bits.
Eg. Determine the octal equivalent of (010111) 2.
Binary 010(MSB) 111(LSB)
number
Octal number 2 7
So, (010111) 2 = (27) 8
Eg.2 Determine the octal equivalent of (0.1110110) 2
Binary No. 000 11 011 000
1
Octal No. 0 7 3 0
So, (0.1110110) 2 = (0.730) 8

Werabe University Institute of Technology Page 8


Computer Applications in Management

9. Conversion of Octal to Binary: The following steps are used here: -


1 Convert the octal digit to its 3-bit binary equivalent.
2 Combine the 3-bit sections by removing the spaces to get the binary.
E.g. determine the binary equivalent of (231) 8

Octal number 2 3 1
Binary 010 011 001
number
So, (231) 8 = (010011001) 2

10. Conversion of Decimal to Hexadecimal:


To convert a decimal number into its hexadecimal equivalent, the same
procedure is adopted as decimal to binary but the decimal number is
divided by 16 (the base of the hexadecimal number system). E.g.
determine the hexadecimal equivalent of (5112) 10 .

16

16 319 8=8
16 19 15=F
16 1 3=3
16 0 1=1 Most Significant Bit (MSB) So, (5112) 10 =
(13F8) 16
11. Conversion of Decimal fractions to Hexadecimal fractions: To
perform this operation we follow the following steps.
1. Multiply the decimal fraction by 16 (the base of the
hexadecimal system).
2. If a whole number is generated, record the whole number
otherwise place 0.
3. Repeat steps 1 and 2 with decimal fraction until it becomes 0.
4. Finally, when no more multiplication can occur, write down the
remainders in the down ward direction.
E.g. determine the hexadecimal equivalent of (0.625) 10

0.625 x 16 = 10.000 10
0.000 x 16 = 0.000 0
So, (0.625) 10 = (0.A0) 16

Werabe University Institute of Technology Page 9


Computer Applications in Management

12. Conversion of Hexadecimal to Decimal: In this case, each digit of


the hexadecimal number is multiplied by its weighted position and each
weighted values are added together to get the decimal number.
E.g. determine the decimal equivalent of (B14) 16 .
(B14) 16 = (B x 162) + (1 x 161) + (4 x 160)
= (11 x 256) + (16) + (4)
= 2836
Que. Determine the decimal equivalent of (8AFE2B) .
16

13. Conversion of hexadecimal fractions to Decimal fractions: steps


1. Write the weighted value of each bit of the hexadecimal fractional
number.
2. Multiply the weighted position with the respective bit of the
hexadecimal fractional number.
3. Add all the weighted values to get the decimal number.
E.g. determine the decimal equivalent of (A.23) 16

0 -1 -2
(A.23) 16 = (A x 16 ) + (2 x 16 ) + (3 x 16 )
=10 + 0.125 + 0.01171875
= 10.13671875
14. Conversion of Binary to hexadecimal: Steps
1. Break the binary number into 4-bit sections starting from the LSB to
the MSB.
2. Convert the 4-bit binary number to its hexadecimal equivalent. E.g.
determine the hexadecimal equivalent of (11001011) 2.
Binary 1100 1011
number
Decimal 12 11
number
Hexadecimal C (MSB) B (LSB)
number
So (11001011) 2 = (CB) 16
Que. Determine the hexadecimal equivalent of
(101011110011011001) 2.
15. Conversion of Hexadecimal to Binary: Steps that are followed here
are the following

Werabe University Institute of Technology Page 10


Computer Applications in Management

1. Convert each hexadecimal digit to its 4-bit binary equivalent.


2. Combine the 4-bit sections by removing the spaces to get the binary
number. E.g. determine the binary equivalent of (5AF) 16 .
Hexadecimal 5 A F
number
Binary value 0101 1010 1111
So, (5AF) 16 = (010110101111) 2.
Que. Determine the binary equivalent of (2B.6C) 16.
Arithmetic System
During school days, arithmetic was restricted only to decimal number
system. However, in computer, we require arithmetic on other number
systems such as binary, octal and hexadecimal.
1. Binary arithmetic: Everything that is stored in or manipulated by the
computer is a number. The computer understands the numbers 1 and 0.
The basic arithmetic operations of the binary number system are:
Addition and subtraction.
I. Binary Addition: Binary addition is carried out in the same way as the
decimal addition is performed. There are four outcomes or rules of the
binary addition.

These are shown below:


Input Output
X Y Sum (S) Carry (R)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

E.g. add the binary numbers 1111 and 1010.


1 1 1 1
Werabe University Institute of Technology Page 11
Computer Applications in Management

+ 1 0 1 0
1 1 0 0 1 Thus the binary sum is (11001) 2.
II. Binary Subtraction: Subtraction is generally simple in comparison to
addition since only two numbers are involved. In binary subtraction the
problem ‘borrow’ is similar to that in decimal. If the subtrahend bit is
equal to or smaller than the minuend bit, then perform subtraction,
otherwise borrow one from its left most neighbor. Binary subtractions
follow four rules for the operation.
Inpu Output
t
X Y Difference (D) Borrow (B)
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
E.g. find the binary difference of (1101-1011).
Binary Decimal
1 0 1 1 1 1
- 1 0 0 1 - 9
0 0 1 0 0 2

Thus the binary difference is (0010) 2.


2. Octal Arithmetic: The essential arithmetic operations of the octal
number system are:
• Addition
• Subtraction
i. Octal Addition: Addition of the octal number is carried out in the same
way as the decimal addition is performed. The steps are given below:
1. First, add the two digits of the unit column of the octal number in
decimal.
2. This process is repeated for each larger significant digit of the octal
number.

Werabe University Institute of Technology Page 12


Computer Applications in Management

3. During the process of addition, if the sum is less than or equal to 7,


then it can be directly written as an octal digit.
4. If the sum is greater than 7, then subtract 8 from that particular digit
and carry 1 to the next digit position.
E.g. Add the octal numbers 26 and 17.
6 2
+ 7 1
4 13
- 8
4 5 Thus the octal sum is (45) 8.
ii. Octal Subtraction: In the octal subtraction, the method, which we have
adopted, is similar to that of binary subtraction method. The only
difference lies in the carry part. During octal subtraction instead of 1, we
will borrow 8 and the rest of steps are similar to that of binary
subtraction.
E.g. Subtract (667) 8 from (770) 8.
7 7 0
- 6 6 7
1 0 1 Thus, the difference is (101) 8.

3. Hexadecimal Arithmetic: Hexadecimal number system is extensively


used in the memories of the computer system and in the computer
instructions. The basic arithmetic operations that are to be performed are
listed below:
• Addition
• Subtraction
I. Hexadecimal Addition: The addition operation performed with the
hexadecimal numbers is analogous to the decimal addition except with a
few differences that are discussed in the following steps:
1 First add the unit column of the hexadecimal digits in decimal.
2 This process is repeated for each larger significant digit of the
hexadecimal number.

Werabe University Institute of Technology Page 13


Computer Applications in Management

3 During the process of addition, observe if the sum is 15 or less, then it


can be directly expressed as hexadecimal digit.
4 If the sum is greater than 15, then subtract 16 from that particular
digit and carry 1 to the next digit position.
E.g. Add the hexadecimal numbers (A27E9) 16 and (6FB43) .
16
A 2 7 E 9
+ 6 F B 4 3
1 17 18 19 18 12
-16 -16 -16 -16 -
1 2 3 2 12(=C)
Thus the hexadecimal sum is (11232C) 16

II. Hexadecimal Subtraction: The hexadecimal subtraction is based on


the same principles as of binary subtraction. In this subtraction, 16 will
be used as borrow instead of 1. The rest of steps are similar to the binary
subtraction.
E.g. Subtract (75) 16 from (527) 16

5 2 7
- 7 5
4 11 2
4 B 2 (Hex form)
Thus the hexadecimal difference is (4B2) .
16

Que. Subtract (1F65) 16 from (7E2CA) .


16

Werabe University Institute of Technology Page 14

You might also like