0% found this document useful (0 votes)
12 views15 pages

Chapter 3

Chapter Three discusses data representation and number systems, highlighting that data can take various forms such as numbers, text, and images. It categorizes number systems into positional and non-positional, with modern computers primarily using binary (base 2), decimal (base 10), octal (base 8), and hexadecimal (base 16) systems. The chapter also explains conversion methods between these number systems, emphasizing the significance of binary in computing.

Uploaded by

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

Chapter 3

Chapter Three discusses data representation and number systems, highlighting that data can take various forms such as numbers, text, and images. It categorizes number systems into positional and non-positional, with modern computers primarily using binary (base 2), decimal (base 10), octal (base 8), and hexadecimal (base 16) systems. The chapter also explains conversion methods between these number systems, emphasizing the significance of binary in computing.

Uploaded by

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

Chapter Three

Data Representation and Number Systems

Data Representation
A computer is a machine that process data, and understand the nature of that data. Data can be
found in different forms like as a number, text, images audio & video. 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.
- Eventually, the number systems that can are generally used by the computers are:
 Decimal system
 Binary system
 Octal system
 Hexadecimal system

Page 1
Number system Radix value Set of Digits Example

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
Hexadecimal r = 16 (0,1,2,3,4,5,6,7,8,9,A, (1A)16
B,C,D,E,F)
al Number system
o It is the primary number system used. Derived from the Latin word ‘Decimal’, which
means ten.
o 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
o 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)

Binary Number System


o 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.
o 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 nth bit of the number from Right Hand Side (RHS) is nth bit x 2n-1

Calculating decimal equivalent –


Step Binary number Decimal number
Step1 101012 ((1*24) +(0*23) +(1*22) +(0*21) +(1*20))10
Step2 101012 (16+0+4+0+1)10
Step3 101012 2110
Note- 101012 is normally written as 10101.

Page 2
Octal Number System
Octal number system

o 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 Number Decimal Number Octal 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)

Table 1: Binary-Decimal-Octal Comparison

Example Octal number: 125708


Calculating decimal equivalent –
Step Octal Decimal number
number
Step1 125708 ((1*84) +(2*83) +(5*82) +(7*81) +(0*80))10
Step2 125708 (4096+1024+320+56+0)10
Step3 125708 549610

Note- 125708 is normally written as 12570.

Page 3
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 Hex Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111

Table 2: Decimal-Hexadecimal-Binary Comparison

Example Hexadecimal number: 19FDE16 Calculating decimal equivalent –


Ste Hexadecimal Decimal number
p number
Step 19FDE16 ((1*164) +(9*163) +(F*162) +(D*161) +(E*160))10
1
Step 19FDE16 ((1*164) +(9*163) +(15*162) +(13*161)
0
2 +(14*16 ))10
Step 19FDE16 (65536+36864+3840+208+14)10
3
Step 19FDE16 549610
4

Note- 19FDE16 is normally written as 19FDE.

Page 4
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.
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

Page 5
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).
Eg. Determine the octal equivalent of (359) 10

8 359 Remainder Least Significant Bit (LSB)


8 44 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.
(456) 8 = (4 x 82) + (5 x 81) + (6 x 80)
= 256 + 40 + 6
= (302) 10

Page 6
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 number 010(MSB) 111(LSB)
Octal number 2 7
So, (010111) 2 = (27) 8
Eg.2 Determine the octal equivalent of (0.1110110) 2
Binary No. 000 111 011 000
Octal No. 0 7 3 0
So, (0.1110110) 2 = (0.730) 8
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 number 010 011 001
So, (231) 8 = (010011001) 2

Page 7
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 5112 Remaineder
Least Significant Bit (LSB)
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
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

Page 8
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
(A.23) 16 = (A x 160) + (2 x 16-1) + (3 x 16-2)
=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 number 1100 1011
Decimal number 12 11
Hexadecimal number C (MSB) B (LSB)
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
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 number 5 A F
Binary value 0101 1010 1111
So, (5AF) 16 = (010110101111) 2.

Page 9
Decimal to Other Base System
Step 1- Divide the decimal number to be converted the value of the new base.
Step 2-Devide the Quotient until the quotient became 0
Step 3-Store or Save the remainder starting from bottom to top
The last remainder thus obtained will be the Most Significant Digit (MSD) of the new base number.
Example Decimal Number: 2910
Calculating Binary Equivalent
Step Operation Result Remainder
Step1 29/2 14 1
Step2 14/2 7 0
Step3 7/2 3 1
Step4 3/2 1 1
Step5 ½ 0 1
As mentioned in Step2 and 4, the remainders have to be arranged in the reverse order so that the
first remainder becomes the Least Significant Digit (LSD) and the last remainder becomes the Most
Significant Digit (MSD).
Decimal Number: 29/210=Binary Number: 111012.
Other Base System to Decimal
Step1 -Determine the column (positional) value of each digit (this depends on the position of the
digit and the base of the number system).
Step2 –Multiplied the obtained column values (in step1) by the digits in the corresponding
columns.
Step3 –Sum the products calculated in step2. The total is the equivalent value in decimal.
Example Binary number: 101012
Calculating decimal equivalent –
Step Binary Decimal number
number
Step1 101012 ((1*24) +(0*23) +(1*22) +(0*21) +(1*20))10
Step2 101012 (16+0+4+0+1)10
Step3 101012 2110
Binary Number: 111012=Decimal Number: 2910
Other Base System to Non-Decimal
Step1 –Convert the original number in to decimal number (base 10).
Step2 –Convert the decimal number so obtained to the new base number.
Example Octal number: 258
Calculating Binary Equivalent
Step1 –Convert to Decimal
Step Octal Number Decimal Number
Step1 258 ((2*81) +(5*80))10
Step2 258 (16+5)10
Step3 258 2110
Octal Number: 258=Decimal Number: 2110

Page 10
Step2 –Convert Decimal to Binary
Step Operation Result Remainder
Step1 21/2 10 1
Step2 10/2 5 0
Step3 5/2 2 1
Step4 2/2 1 0
Step5 ½ 0 1
Decimal Number: 2110=Binary Number: 101012
Shortcut Method-Binary to Octal
Step1-Devide the binary digits into groups of three (starting from the right).
Step2-Convert each group of three binary digits to one octal digit.
Example Binary Number: 101012
Calculating Octal Equivalent
Step Binary Number Octal Number
Step1 101012 010 101
Step2 101012 28 58
Step3 101012 258
Binary Number: 101012=Octal Number: 258
Shortcut Method- Octal to Binary
Step1 Convert each octal digit to a 3-digit binary number (the octal digits may be treated as decimal
for this conversion).
Step2 Combine all the resulting binary groups (of 3 digits each)into a single binary number.
Example Octal Number: 258
Calculating Binary Equivalent
Step Octal Number Binary Number
Step1 258 210 510
Step2 258 0102 1012
Step3 258 0101012
Octal Number: 258=Binary Number: 101012
Shortcut Method-Binary to Hexadecimal
Step1 Divide the binary digits into groups of four (starting from the right).
Step2 Convert each group of four binary digits to one hexadecimal symbol.
Example Binary Number: 101012
Calculating Octal Equivalent
Step Binary Number Hexadecimal Number
Step1 101012 0001 0101
Step2 101012 116 516
Step3 101012 1516
Binary Number: 101012=Hexadecimal Number: 1516

Page 11
Shortcut Method-Hexadecimal to Binary
Step1 Convert each Hexadecimal digit to a 4-digit binary number (the hexadecimal digits may be
treated as decimal for this conversion).
Step2 Combine all the resulting binary groups (of 4 digits each) into a single binary number.
Example Hexadecimal Number: 1516
Calculating Binary Equivalent
Step Hexadecimal Number Binary Number
Step1 1516 110 510
Step2 1516 00012 01012
Step3 1516 000101012

Hexadecimal Number: 1516=Binary Number: 101012

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.
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 1 1
+ 1 0 1 0
1 1 0 0 1 Thus the binary sum is (11001) 2.

Page 12
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.
Input Output
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

0 10
1 1 0 1 1 3
- 1 0 1 1 - 1 1
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.
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

Page 13
E.g. Add the octal numbers 26 and 17.
1 (carry)
2 6
+ 1 7
4 13
- 8
4 5 Thus the octal sum is (45) 8.
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.
8+6=14
6 6 8 (Borrow)
7 7 0
- 6 6 7
1 0 1 Thus, the difference is (101) 8.

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
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.
3. During the process of addition, observe if the sum is 15 or less, then it can be
directly expressed as hexadecimal digit.

Page 14
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.

1 1 1 1 1 1
A 2 7 E 9
+ 6 F B 4 3
1 17 18 19 18 12
-16 -16 -16 -16 -
1 1 2 3 2 12(=C) Thus the hexadecimal sum is (11232C) 16
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.
4 16+2=18 (Borrow)
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.


1. The number is changed to binary.
2. If the number of bits is less than N (Where N is the number of bits allocated to represent the
integer), O’s are added to the left of the binary number so that there is a total of N bits.
EXAMPLE: Store 7 in an 8-bit memory location.
I. First change the number to binary 111

ii. A d d five 0’s to make a total of N (8) bits 00000111. Therefore, the number is stored in
the memory location.

Page 15

You might also like