Page 1
37
Data Representation in Computers
After studying this chapter the student will be able to:
*Learn about binary, octal, decimal and hexadecimal number systems
*Learn conversions between two different number systems
*Understand internal storage encoding of characters: ASCII, ISCII and UNICODE
Binary Representation of Data
In order to work with data, the data must be represented inside the computer. Digital
computers represent data by means of an easily identified symbol called a digit.
Numbering Systems
Each number system has a base also called a Radix. A decimal number system is a
system of base 10; binary is a system of base 2; octal is a system of base 8; and
hexadecimal is a system of base 16. What are these varying bases? The answer lies in
what happens when we count up to the maximum number that the numbering system
allows. In base 10, we can count from 0 to 9, that is,10 digits.
Number System Base Symbols used
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
where A = 10; B = 11; C = 12; D = 13;
E = 14; F = 15
Page 2
37
Data Representation in Computers
After studying this chapter the student will be able to:
*Learn about binary, octal, decimal and hexadecimal number systems
*Learn conversions between two different number systems
*Understand internal storage encoding of characters: ASCII, ISCII and UNICODE
Binary Representation of Data
In order to work with data, the data must be represented inside the computer. Digital
computers represent data by means of an easily identified symbol called a digit.
Numbering Systems
Each number system has a base also called a Radix. A decimal number system is a
system of base 10; binary is a system of base 2; octal is a system of base 8; and
hexadecimal is a system of base 16. What are these varying bases? The answer lies in
what happens when we count up to the maximum number that the numbering system
allows. In base 10, we can count from 0 to 9, that is,10 digits.
Number System Base Symbols used
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
where A = 10; B = 11; C = 12; D = 13;
E = 14; F = 15
38
Converting a number from one Base to another:
Binary to Decimal
Method to convert Binary to Decimal:
1. Start at the rightmost bit.
2. Take that bit and multiply by 2
n
where n is the current position beginning at 0 and
increasing by 1 each time. This represents a power of two.
3. Sum each terms of product until all bits have been used.
Example
Convert the Binary number 101011 to its Decimal equivalent.
1 * 2
5
+ 0 * 2
4
+ 1 * 2
3
+ 0 * 2
2
+
1 * 2
1
+ 1 * 2
0
32 + 0 + 8 + 0 +2 + 1 = (43)10
Example
Convert the Binary number 1001 to its Decimal equivalent.
1 * 2
3
+ 0 * 2
2
+ 0 * 2
1
+ 1 * 2
0
8 + 0 + 0 + 1 = (9)10
Binary fraction to decimal
Example
Convert (11011.101)2 to decimal
2
4
2
3
2
2
2
1
.
2
0
2
-1
2
-2
2
-3
1 1 0 1 1 1 0 1
= (1 x 2
4
)+
(1 x 2
3
)+
(0 x 2
2
)+
(1 x 2
1
)+
(1 x 2
0
)+
(1 x 2
-1
)+
(0 x 2
-2
)+
(1 x 2
-3
)
= 16+8+0+2+1+0.5+0+0.125
= (27.625)10
Decimal to Binary
Method to convert a Decimal number into its Binary equivalent:
Page 3
37
Data Representation in Computers
After studying this chapter the student will be able to:
*Learn about binary, octal, decimal and hexadecimal number systems
*Learn conversions between two different number systems
*Understand internal storage encoding of characters: ASCII, ISCII and UNICODE
Binary Representation of Data
In order to work with data, the data must be represented inside the computer. Digital
computers represent data by means of an easily identified symbol called a digit.
Numbering Systems
Each number system has a base also called a Radix. A decimal number system is a
system of base 10; binary is a system of base 2; octal is a system of base 8; and
hexadecimal is a system of base 16. What are these varying bases? The answer lies in
what happens when we count up to the maximum number that the numbering system
allows. In base 10, we can count from 0 to 9, that is,10 digits.
Number System Base Symbols used
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
where A = 10; B = 11; C = 12; D = 13;
E = 14; F = 15
38
Converting a number from one Base to another:
Binary to Decimal
Method to convert Binary to Decimal:
1. Start at the rightmost bit.
2. Take that bit and multiply by 2
n
where n is the current position beginning at 0 and
increasing by 1 each time. This represents a power of two.
3. Sum each terms of product until all bits have been used.
Example
Convert the Binary number 101011 to its Decimal equivalent.
1 * 2
5
+ 0 * 2
4
+ 1 * 2
3
+ 0 * 2
2
+
1 * 2
1
+ 1 * 2
0
32 + 0 + 8 + 0 +2 + 1 = (43)10
Example
Convert the Binary number 1001 to its Decimal equivalent.
1 * 2
3
+ 0 * 2
2
+ 0 * 2
1
+ 1 * 2
0
8 + 0 + 0 + 1 = (9)10
Binary fraction to decimal
Example
Convert (11011.101)2 to decimal
2
4
2
3
2
2
2
1
.
2
0
2
-1
2
-2
2
-3
1 1 0 1 1 1 0 1
= (1 x 2
4
)+
(1 x 2
3
)+
(0 x 2
2
)+
(1 x 2
1
)+
(1 x 2
0
)+
(1 x 2
-1
)+
(0 x 2
-2
)+
(1 x 2
-3
)
= 16+8+0+2+1+0.5+0+0.125
= (27.625)10
Decimal to Binary
Method to convert a Decimal number into its Binary equivalent:
39
1. Divide the decimal number by 2.
2. Take the remainder and record it on the side.
3. Divide the quotient by 2.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary number.
Example
Convert the Decimal number 125 into its Binary equivalent.
125 / 2 = 62 1
62 / 2 = 31 0
31 / 2 = 15 1
15 / 2 = 7 1
7 / 2 = 3 1
3 / 2 = 1 1
1 / 2 = 0 1
Answer: (1111101)2
Converting Decimal fraction to Binary
Example
Convert (0.75)10 to binary
Multiply the given fraction by 2. Keep the integer in the product as it is and multiply
the new fraction in the product by 2. Continue the process till the required number of
decimal places or till you get zero in the fraction part. Record the integers in the
products from top to bottom.
Given fraction 0.75
Multiply 0.75 by 2 1.50
Multiply 0.50 by 2 1.00
Reading the integers from top to bottom 0.75 in decimal number system is 0.11 in binary
number system.
Page 4
37
Data Representation in Computers
After studying this chapter the student will be able to:
*Learn about binary, octal, decimal and hexadecimal number systems
*Learn conversions between two different number systems
*Understand internal storage encoding of characters: ASCII, ISCII and UNICODE
Binary Representation of Data
In order to work with data, the data must be represented inside the computer. Digital
computers represent data by means of an easily identified symbol called a digit.
Numbering Systems
Each number system has a base also called a Radix. A decimal number system is a
system of base 10; binary is a system of base 2; octal is a system of base 8; and
hexadecimal is a system of base 16. What are these varying bases? The answer lies in
what happens when we count up to the maximum number that the numbering system
allows. In base 10, we can count from 0 to 9, that is,10 digits.
Number System Base Symbols used
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
where A = 10; B = 11; C = 12; D = 13;
E = 14; F = 15
38
Converting a number from one Base to another:
Binary to Decimal
Method to convert Binary to Decimal:
1. Start at the rightmost bit.
2. Take that bit and multiply by 2
n
where n is the current position beginning at 0 and
increasing by 1 each time. This represents a power of two.
3. Sum each terms of product until all bits have been used.
Example
Convert the Binary number 101011 to its Decimal equivalent.
1 * 2
5
+ 0 * 2
4
+ 1 * 2
3
+ 0 * 2
2
+
1 * 2
1
+ 1 * 2
0
32 + 0 + 8 + 0 +2 + 1 = (43)10
Example
Convert the Binary number 1001 to its Decimal equivalent.
1 * 2
3
+ 0 * 2
2
+ 0 * 2
1
+ 1 * 2
0
8 + 0 + 0 + 1 = (9)10
Binary fraction to decimal
Example
Convert (11011.101)2 to decimal
2
4
2
3
2
2
2
1
.
2
0
2
-1
2
-2
2
-3
1 1 0 1 1 1 0 1
= (1 x 2
4
)+
(1 x 2
3
)+
(0 x 2
2
)+
(1 x 2
1
)+
(1 x 2
0
)+
(1 x 2
-1
)+
(0 x 2
-2
)+
(1 x 2
-3
)
= 16+8+0+2+1+0.5+0+0.125
= (27.625)10
Decimal to Binary
Method to convert a Decimal number into its Binary equivalent:
39
1. Divide the decimal number by 2.
2. Take the remainder and record it on the side.
3. Divide the quotient by 2.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary number.
Example
Convert the Decimal number 125 into its Binary equivalent.
125 / 2 = 62 1
62 / 2 = 31 0
31 / 2 = 15 1
15 / 2 = 7 1
7 / 2 = 3 1
3 / 2 = 1 1
1 / 2 = 0 1
Answer: (1111101)2
Converting Decimal fraction to Binary
Example
Convert (0.75)10 to binary
Multiply the given fraction by 2. Keep the integer in the product as it is and multiply
the new fraction in the product by 2. Continue the process till the required number of
decimal places or till you get zero in the fraction part. Record the integers in the
products from top to bottom.
Given fraction 0.75
Multiply 0.75 by 2 1.50
Multiply 0.50 by 2 1.00
Reading the integers from top to bottom 0.75 in decimal number system is 0.11 in binary
number system.
40
Example
Convert (105.15)10 to binary
Let us convert 105 first.
(105)10 = (1101001)2
Let us convert (0.15) 10
Multiply 0.15 by 2 0.30
Multiply 0.30 by 2 0.60
Multiply 0.60 by 2 1.20
Multiply 0.20 by 2 0.40
Multiply 0.40 by 2 0.80
Multiply 0.80 by 2 1.60
Reading the integers from top to bottom (0.15)10 = (0.001001)2
Final result (105.15) 10 = (1101001.001001)2
Decimal to Octal
The method to convert a decimal number into its octal equivalent:
1. Divide the decimal number by 8.
2. Take the remainder and record it on the side.
3. Divide the quotient by 8.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary
Example
Convert the Decimal number 125 into its Octal equivalent.
125 / 8 = 15 5
15/ 8 = 1 7
1/8 =0 1
Page 5
37
Data Representation in Computers
After studying this chapter the student will be able to:
*Learn about binary, octal, decimal and hexadecimal number systems
*Learn conversions between two different number systems
*Understand internal storage encoding of characters: ASCII, ISCII and UNICODE
Binary Representation of Data
In order to work with data, the data must be represented inside the computer. Digital
computers represent data by means of an easily identified symbol called a digit.
Numbering Systems
Each number system has a base also called a Radix. A decimal number system is a
system of base 10; binary is a system of base 2; octal is a system of base 8; and
hexadecimal is a system of base 16. What are these varying bases? The answer lies in
what happens when we count up to the maximum number that the numbering system
allows. In base 10, we can count from 0 to 9, that is,10 digits.
Number System Base Symbols used
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
where A = 10; B = 11; C = 12; D = 13;
E = 14; F = 15
38
Converting a number from one Base to another:
Binary to Decimal
Method to convert Binary to Decimal:
1. Start at the rightmost bit.
2. Take that bit and multiply by 2
n
where n is the current position beginning at 0 and
increasing by 1 each time. This represents a power of two.
3. Sum each terms of product until all bits have been used.
Example
Convert the Binary number 101011 to its Decimal equivalent.
1 * 2
5
+ 0 * 2
4
+ 1 * 2
3
+ 0 * 2
2
+
1 * 2
1
+ 1 * 2
0
32 + 0 + 8 + 0 +2 + 1 = (43)10
Example
Convert the Binary number 1001 to its Decimal equivalent.
1 * 2
3
+ 0 * 2
2
+ 0 * 2
1
+ 1 * 2
0
8 + 0 + 0 + 1 = (9)10
Binary fraction to decimal
Example
Convert (11011.101)2 to decimal
2
4
2
3
2
2
2
1
.
2
0
2
-1
2
-2
2
-3
1 1 0 1 1 1 0 1
= (1 x 2
4
)+
(1 x 2
3
)+
(0 x 2
2
)+
(1 x 2
1
)+
(1 x 2
0
)+
(1 x 2
-1
)+
(0 x 2
-2
)+
(1 x 2
-3
)
= 16+8+0+2+1+0.5+0+0.125
= (27.625)10
Decimal to Binary
Method to convert a Decimal number into its Binary equivalent:
39
1. Divide the decimal number by 2.
2. Take the remainder and record it on the side.
3. Divide the quotient by 2.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary number.
Example
Convert the Decimal number 125 into its Binary equivalent.
125 / 2 = 62 1
62 / 2 = 31 0
31 / 2 = 15 1
15 / 2 = 7 1
7 / 2 = 3 1
3 / 2 = 1 1
1 / 2 = 0 1
Answer: (1111101)2
Converting Decimal fraction to Binary
Example
Convert (0.75)10 to binary
Multiply the given fraction by 2. Keep the integer in the product as it is and multiply
the new fraction in the product by 2. Continue the process till the required number of
decimal places or till you get zero in the fraction part. Record the integers in the
products from top to bottom.
Given fraction 0.75
Multiply 0.75 by 2 1.50
Multiply 0.50 by 2 1.00
Reading the integers from top to bottom 0.75 in decimal number system is 0.11 in binary
number system.
40
Example
Convert (105.15)10 to binary
Let us convert 105 first.
(105)10 = (1101001)2
Let us convert (0.15) 10
Multiply 0.15 by 2 0.30
Multiply 0.30 by 2 0.60
Multiply 0.60 by 2 1.20
Multiply 0.20 by 2 0.40
Multiply 0.40 by 2 0.80
Multiply 0.80 by 2 1.60
Reading the integers from top to bottom (0.15)10 = (0.001001)2
Final result (105.15) 10 = (1101001.001001)2
Decimal to Octal
The method to convert a decimal number into its octal equivalent:
1. Divide the decimal number by 8.
2. Take the remainder and record it on the side.
3. Divide the quotient by 8.
4. REPEAT UNTIL the decimal number cannot be divided further.
5. Record the remainders in reverse order and you get the resultant binary
Example
Convert the Decimal number 125 into its Octal equivalent.
125 / 8 = 15 5
15/ 8 = 1 7
1/8 =0 1
41
Answer: (175)8
Converting Decimal fraction to Octal
Example
Convert (0.75)10 to Octal
Multiply the given fraction by 8. Keep the integer in the product as it is and multiply
the new fraction in the product by 8. Continue the process and read the integers in the
products from top to bottom.
Given fraction 0.75
Multiply 0.75 by 8 6.00
Reading the integers from top to bottom 0.75 in decimal number system is 0.6 in octal
number system.
Octal to Decimal
Method to convert Octal to Decimal:
1. Start at the rightmost bit.
2 . Take that bit and multiply by 8
n
where n is the current position beginning at 0 and
increasing by 1 each time. This represents the power of 8.
3. Sum each of the product terms until all bits have been used.
Example
Convert the Octal number 321 to its Decimal equivalent.
3 * 8
2
+ 2 * 8
1
+ 1 * 8
0
192+16+ 1 = (209)10
Octal fraction to decimal
Example
Convert (23.25)8 to decimal
8
1
8
0
.
8
-1
8
-2
2 3 2 5
Read More