Chapter Four
Data Representation in Computers
The basic unit of the memory is a Bit. A Bit is an abbreviation for a Binary digit and can
be either a 0 or a 1.
Group of continuous 4 bits is termed as Nibble.
Eight adjacent bits designed to store the binary code of a single character (letter, decimal
digit or other character) is referred as Byte.
A word is a fixed-sized group of bits that are handled together by the machine. The
number of bits in a word (the word size or word length) is an important characteristic
of computer architecture.
A Word consists of 32 bits, which is equal to 4 bytes (this depends on the computer i.e.,
a word may contain 8, 16, or 32 bits). Commonly used notation in modern computers is
32 bits.
Double word is 2 times a word.
Frequently capacity of memory is represented in terms of K (Kilo) , which is equivalent
to 1024 words of 8 bits each ( 210 bytes ).
1 KILO = 1024 bytes (approx. 103 bytes) These are all the
1 MEGA = 210 K B approximate values
1 GIGA = 210 M B B stands for Byte
1 TERA = 210 G B
1 PETA = 210 TERA B
A computer’s internal storage techniques are different from the way people represent
information in lives.
Information inside a digital computer is stored as a collection of binary data (0’s and 1’s)
It was easier to make hardware which can distinguish between two values than multiple
values.
Other bases need more circuitry as compared to binary and this reduced reliability.
This binary system simplifies the design of the circuits, reduces the cost and improves the
reliability.
Every operation that can be done in decimal system can also be done in binary.
Hexa decimal
Decimal System Binary System Octal System
System
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
: : : :
: : : :
Binary to Decimal
(For conversion of a binary number to a decimal number the base / radix will be 2)
Example 1 Convert binary (1100)2 to decimal form.
Solution
Digit Positional value(Step 1) Step 2
0(right most digit) 20 0*20
0 21 0*21
1 22 1*22
1 23 1*23
Total (Step 3) 4+8=12
Therefore 11002 =1210
Example 2 Convert binary (11101101.10101)2 to decimal form.
Solution
Integer part – 11101101
Fractional part – 10101
Conversion of integer part :
1×27 + 1×26 + 1×25 + 0×24 + 1×23 + 1×22 + 0×21 + 1×20
1×128 + 1×64 + 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1
128 + 64 + 32 + 0 + 8 + 4 + 0 + 1
(237)10
Conversion of fractional part :
Starting from left to right each bit is multiplied by
2–1, 2–2, 2–3, 2–4...... we find
1 0 1 0 1
———–––––––––
1×2 + 0×2–2 + 1×2–3 + 0×2–4 + 1×2–5
–1
Useful Tips
+ve Power of 2 Equivalent value –ve Power of 2 Equivalent values
20 1 2–1 .50
21 2 2–2 .25
22 4 2–3 .125
23 8 2–4 .0625
24 16 2–5 .03125
25 32 2–6 .015625
26 64 2–7 .0078125
27 128 2–8 .00390625
28 256 2–9 .001953125
29 512 2–10 .000976562
210 1024 2–11 .000488281
Note : A binary number having all 1s and without fractional part can be
converted into decimal number system by the following direct conversion
formula : 2n-1, where n is the total number of bits in the binary number.
Example
Convert Binary 11 into its decimal equivalent: (11)2 = (?)10
Here n = 2 2n–1 = 22–1 = (3)10
Octal to Decimal
(For conversion of an octal number to a decimal number the base / radix will be 8.)
Example 1 Convert octal number (172)8 to decimal (?)10
Solution
Conversion of integer part : Starting from right multiply each digit by its positional value , we find
1 7 2
1×82 + 7×81 + 2×80
1×64 + 7×8 + 2×1
64 + 56 + 2
(122)10.The converted decimal equivalent value we find is (172)8 = (122)10
Example 2
Convert (342.671)8 to decimal (?)10 form.
Solution
Integer part – 342
Fractional part – 671
Conversion of integer part Conversion of fractional part
3 4 2 Starting from left to right each digit is multiplied by
3×8 2 + 4×81 + 2×80 8–1, 8–2, 8–3, 8–4...... we find –
3×64 + 4×8 + 2×1 6 7 1
192 + 32 + 2 –1
6×8 + 7×8 –2 + 1×8–3
(226)10 0.75 + 0.1093 + 0.00195 = (0.86125)10
By combining both the converted values we get the final decimal equivalent (226.86125)10
+
0.0625 + 0.039062 = (0.101562)10
by combining both the values we get the final decimal equivalent.
(1502.101562)10
Repeat steps 3 and 4 recording remainders from right to left, until the quotient becomes
zero in step 3. Note that the last remainder thus obtained will be the most significant digit (MSD)
of the new base number.
Example 1
Now the combined string of converted integer and fractional part will be
(75.68)10 = (1001011.10101)2
Example 3: Find the Octal equivalent of (634.640625)10 = ( ? )8
Solution
Integer part conversion
(Divisor) Dividend divisor = Quotient (Remainder)
8 634 8 = 79 2 R1 LSD
8 79 8 = 9 7 R2
8 9 8 = 9 1 R3 (1172)8
8 1 8 = 0 1 R4 MSD
Eg: 3456 =? 4
First, Convert 3456 into its equivalent decimal.
=5*60+4*61+3*62 Now, convert 137 10 =? 4
=5+24+108 137 1
=13710 34 8 2
8 2 0
So, 3456 = 20214 2 2
Step 1: Divide the binary digits into groups of three (starting from the right). If any last group does
not have sufficient bits to make the pair of 3 bits then some 0 bits can be included to the left
to make the group of 3 bits.
Step 2: Convert each group of 3 binary digits into one octal digit. Since decimal digits 0 to 7 are
equal to octal digits 0 to 7, binary to decimal conversion can be used in this step.
(b) Fractional part conversion
Step 1: Here the grouping of 3 bits is done from left to right and if any last group does not have sufficient
number of bits then adequate zeros can be included to the right of the last group.
Step 2: Now each group of bits is converted into its octal equivalent number.
Step 3: After this if integer part is present all the equivalent octal numbers of integer parts and fractional
parts are combined to find the final octal equivalent number.
Step 4: At last the decimal point is fixed at the appropriate position according to the mathematical
conventions.
Example 1: Find the octal equivalent of (10101.01101)2 = (?)8
Solution
0 1 0 1 0 1 0 1 1 0 1 0
·
2 5 ·
3 2 (10101.01101)2 = (25.32)8
R to L grouping L to R
1. Binary Addition
Rule:
0+1=1
1+0=1
0+0=0
1+1=0, with a carry 1 over to the next higher column.
Add the following number
101 + 11
101
+ 11
1000
Complement or 1’s Complement of Binary Numbers
Complement or 1’s Complement of Binary Numbers
Rule:
Complement of 1 = 0
Complement of 0 = 1
+9 0 1001
+4 + 0 0 1 0 0
----------------
0 1 1 0 1 = +13
Sign bits
+9 0 1001
-4 + 1 1 1 0 0 (-4 is in its 2’s complement representation)
--------------------
1 0 0101 =+5
2. Binary Subtraction
Rule:
1-1=0
1-0=1
0-0=0
0-1=1, a borrow 1 from the next higher column.
Eg: 101-11
101
- 11
010
Binary Subtraction in the 2’s Complement System
Eg: (+9) - (+4)
+9 01001
+4 -00100
Here, +4 is to be changed to its 2’s complement form. i.e, 11100. And now add this number with
+9 (01001) .
+9 0 1001
-4 + 1 1100
-----------------
1 0 0101 =+5
Any subtraction operation, then, actually becomes one of the addition when 2’s complement system is
used. This feature of 2’s complement system allows addition and subtraction to be performed by the same
circuitry- made it the most widely used method.
3. Multiplication of Binary Numbers
Eg: (910 ) * (1110 )
910 = 1 0 0 1 multiplicand
1110 = 1 0 1 1 multiplier
----------
1001
1001
0000
1001
-------------------
1100011 = 9910
4. Division of Binary Numbers
Eg: (910 ) ÷ (310 ) 910 = 1 0 0 1 dividend
310 = 0 0 1 1 divisor
0011 = 310
11 1001
011
------------
0011
0011
------------
0000
Computer Codes
Computer handles different types of data namely numeric data, alphanumeric data, alphabetic
data etc. Computer system use a binary system for data representation; Two digits 0 and 1, refer
to the presence and absence of electric current or pulse of light. All data and programs that go
into the computer are represented in terms of these numbers.
Computer system encodes the data by means of binary or digital coding schemes to
represent letters, numbers and special characters. One of the early coding schemes is BCD. Some
of the commonly used schemes are EBCDIC, ASCII, and Unicode.
BCD (Binary Coded Decimal)
BCD is one of the early memory codes. In BCD each digit of a decimal number is
converted into its binary equivalent rather than converting the entire decimal value into binary
form. And each decimal digit uses 4 bits for this conversion.
This code can represent the following type of coded information. (i) Printable (ii) non printable
(iii) lowercase letters - a, b, c ...... z (iii) upper case letters eg. A, B, C ...... Z (iv) numeric values 0, 1, 2
........ 9 (v) some special characters such as + , –, $ etc.
This binary scheme originally used 7 bits to from a character and so known as ASCII- 7 coding
scheme. ASCII 7 can represent only 27 (=128) different characters.
ASCII-8
To provide more possible combinations with which to
form other characters and symbols. Extended ASCII
ASCII-8 Coding Scheme for All
or ASCII-8 was introduced. ASCII-8 use 8 bits to Numeric and Alphabetic
form a character and can represent 28 (=256) different Characters
characters.