DATA REPRESENTATION IN A COMPUTER
1. Introduction
 Computers are classified according to functionality, physical size and purpose.
 Functionality, Computers could be analog, digital or hybrid. Digital computers process data that is in discrete form whereas analog computers process data that is continuous in nature. Hybrid computers on the other hand can process data that is both discrete and continuous.
 In digital computers, the user input is first converted and transmitted as electrical pulses that can be represented by two unique states ON and OFF. The ON state may be represented by a “1” and the off state by a “0”.The sequence of ON’S and OFF’S forms the electrical signals that the computer can understand.
 A digital signal rises suddenly to a peak voltage of +1 for some time then suddenly drops 1 level on the other hand an analog signal rises to +1 and then drops to 1 in a continuous version.
 Although the two graphs look different in their appearance, notice that they repeat themselves at equal time intervals. Electrical signals or waveforms of this nature are said to be periodic.Generally,a periodic wave representing a signal can be described using the following parameters
 Amplitude(A)
 Frequency(f)
 periodic time(T)
 Amplitude (A): this is the maximum displacement that the waveform of an electric signal can attain.
 Frequency (f): is the number of cycles made by a signal in one second. It is measured in hertz.1hert is equivalent to 1 cycle/second.
 Periodic time (T): the time taken by a signal to complete one cycle is called periodic time. Periodic time is given by the formula T=1/f, where f is the frequency of the wave.
 When a digital signal is to be sent over analog telephone lines e.g. email, it has to be converted to analog signal. This is done by connecting a device called a modem to the digital computer. This process of converting a digital signal to an analog signal is known as modulation. On the receiving end, the incoming analog signal is converted back to digital form in a process known as demodulation.
2. concepts of data representation in digital computers
 Data and instructions cannot be entered and processed directly into computers using human language. Any type of data be it numbers, letters, special symbols, sound or pictures must first be converted into machinereadable form i.e. binary form. Due to this reason, it is important to understand how a computer together with its peripheral devices handles data in its electronic circuits, on magnetic media and in optical devices.
Data representation in digital circuits
 Electronic components, such as microprocessor, are made up of millions of electronic circuits. The availability of high voltage(on) in these circuits is interpreted as ‘1’ while a low voltage (off) is interpreted as ‘0’.This concept can be compared to switching on and off an electric circuit. When the switch is closed the high voltage in the circuit causes the bulb to light (‘1’ state).on the other hand when the switch is open, the bulb goes off (‘0’ state). This forms a basis for describing data representation in digital computers using the binary number system.
Data representation on magnetic media
 The laser beam reflected from the land is interpreted, as 1.The laser entering the pot is not reflected. This is interpreted as 0.The reflected pattern of light from the rotating disk falls on a receiving photoelectric detector that transforms the patterns into digital form.The presence of a magnetic field in one direction on magnetic media is interpreted as 1; while the field in the opposite direction is interpreted as “0”.Magnetic technology is mostly used on storage devices that are coated with special magnetic materials such as iron oxide. Data is written on the media by arranging the magnetic dipoles of some iron oxide particles to face in the same direction and some others in the opposite direction
Data representation on optical media
In optical devices, the presence of light is interpreted as ‘1’ while its absence is interpreted as ‘0’.Optical devices use this technology to read or store data. Take example of a CDROM, if the shiny surface is placed under a powerful microscope, the surface is observed to have very tiny holes called pits. The areas that do not have pits are called land.
Reason for use of binary system in computers
 It has proved difficult to develop devices that can understand natural language directly due to the complexity of natural languages. However, it is easier to construct electric circuits based on the binary or ON and OFF logic. All forms of data can be represented in binary system format. Other reasons for the use of binary are that digital devices are more reliable, small and use less energy as compared to analog devices.
Bits, bytes, nibble and word
 The terms bits, bytes, nibble and word are used widely in reference to computer memory and data size.
 Bits: can be defined as either a binary, which can be 0, or 1.It is the basic unit of data or information in digital computers.
 Byte: a group of bits (8 bits) used to represent a character. A byte is considered as the basic unit of measuring memory size in computer.
 A nibble: is half a byte, which is usually a grouping of 4 bytes.
 Word: two or more bits make a word. The term word length is used as the measure of the number of bits in each word. For example, a word can have a length of 16 bits, 32 bits, 64 bits etc.
Types of data representation
 Computers not only process numbers, letters and special symbols but also complex types of data such as sound and pictures. However, these complex types of data take a lot of memory and processor time when coded in binary form.
 This limitation necessitates the need to develop better ways of handling long streams of binary digits.
 Higher number systems are used in computing to reduce these streams of binary digits into manageable form. This helps to improve the processing speed and optimize memory usage.
Number systems and their representation
 A number system is a set of symbols used to represent values derived from a common base or radix.
 As far as computers are concerned, number systems can be classified into two major categories:
 decimal number system
 binary number system
 octal number system
 hexadecimal number system
Decimal number system
 The term decimal is derived from a Latin prefix deci, which means ten. Decimal number system has ten digits ranging from 09. Because this system has ten digits; it is also called a base ten number system or denary number system.
 A decimal number should always be written with a subscript 10 e.g. X_{10}
 But since this is the most widely used number system in the world, the subscript is usually understood and ignored in written work. However ,when many number systems are considered together, the subscript must always be put so as to differentiate the number systems.
 The magnitude of a number can be considered using these parameters.
 Absolute value
 Place value or positional value
 Base value
 The absolute value is the magnitude of a digit in a number. for example the digit 5 in 7458 has an absolute value of 5 according to its value in the number line.
 The place value of a digit in a number refers to the position of the digit in that number i.e. whether; tens, hundreds, thousands etc.
 The total value of a number is the sum of the place value of each digit making the number.
 The base value of a number also k known as the radix, depends on the type of the number systems that is being used .The value of any number depends on the radix. for example the number 100_{10} is not equivalent to 100_{2}.
Binary number system
Octal number system
Consists of eight digits ranging from 07.the place value of octal numbers goes up in factors of eight from right to left.
Hexadecimal number system
This is a base 16 number system that consists of sixteen digits ranging from 09 and letters AF where A is equivalent to 10,B to 11 up to F which is equivalent to 15 in base ten system. The place value of hexadecimal numbers goes up in factors of sixteen.
 A hexadecimal number can be denoted using 16 as a subscript or capital letter H to the right of the number .For example, 94B can be written as 94B16 or 94BH.
Further conversion of numbers from one number system to another
 To convert numbers from one system to another. the following conversions will be considered.
 Converting between binary and decimal numbers.
 Converting octal numbers to decimal and binary form.
 Converting hexadecimal numbers to decimal and binary form.
 a) Conversion between binary and decimal number
 Converting binary numbers to decimal numbers
 To convert a binary number to a decimal number, we proceed as follows:
 First, write the place values starting from the right hand side.
 Write each digit under its place value.
 Multiply each digit by its corresponding place value.
 Add up the products. The answer will be the decimal number in base ten.
EXAMPLE
Convert 101101_{2} to base 10(or decimal) number
Place value 
2^{5} 
2^{4} 
2^{3} 
2^{2} 
2^{1} 
2^{0} 
Binary digits 
1 
0 
1 
1 
0 
1 
Multiply each digit by its place value
N_{10}=(1*2^{5}) +(0*2^{4})+(1*2^{3})+(1*2^{2})+(0*2^{1})+(1*2^{0}) N_{10}=32+0+8+4+0+1
=45_{10} 
32*1=32
16*0=0
8*1=8 4*1=4
2*0=0
1*1=1
=45_{10}
NB: remember to indicate the base subscript since it is the value that distinguishes the different systems.
Nimetön #0b4a
 The binary equivalent of the fractional part is extracted from the products by reading the respective integral digits from the top downwards as shown by the arrow next page.
 Combine the two parts together to set the binary equivalent.
Convert 0.375_{10} into binary form
Read this digits
0.375×2=0.750
0.750×2=1.500
0.500×2=1.000 (fraction becomes zero)
Therefore 0.375_{10}=0.011_{2}
NB: When converting a real number from binary to decimal, work out the integral part and the fractional parts separately then combine them.
Example
Convert 11.011_{2} to a decimal number.
Solution
Convert the integral and the fractional parts separately then add them up.
2×1= 2.000
1×1= +1.000
3.000_{10}
Weight 
2^{1} 
2^{0} 
. 
2^{1} 
2^{2} 
2^{3} 
Binary digit 
1 
1 
. 
0 
1 
1 
Values in base 10 
2 
1 
. 
0 
0.25 
0.125 
0.50×0 =0.000
0.25×1 =0.250
0.125×1=+0.125
0.375_{10}
3.000_{10}+0.375_{10}= 3.375_{10}
Thus 11.011_{2}=3.375_{10}
 iv) Converting a decimal fraction to binary
Divide the integral part continuously by 2.For the fractional part, proceed as follows:
Multiply the fractional part by 2 and note down the product
 Take the fractional part of the immediate product and multiply it by 2 again.
 Continue this process until the fractional part of the subsequent product is 0 or starts to repeat itself.
Nimetön #0e21

 The following examples illustrate how to convert hexadecimal number to a decimal numberExample
Convert octal number 321_{8 }to its binary equivalent
Solution
Working from left to the right, each octal number is represented using three digits and then combined we get the final binary equivalent. Therefore:
3=011_{2}
2=010_{2}
1=001_{2}
Combining the three from left to right
3
2
1
011
010
001
321_{8 }=011010001_{2}
Converting binary numbers to hexadecimal numbers
 To convert binary numbers to their binary equivalents, simply group the digits of the binary number into groups of four from right to left e.g. 11010001.The next step is to write the hexadecimal equivalent of each group e.g.
1101 D
0001 1
The equivalent of 11010001 is D1H or D1_{16}
Converting hexadecimal numbers to decimal and binary numbers.
Converting hexadecimal numbers to decimal number
 To convert hexadecimal number to base 10 equivalent we proceed as follows:
 First, write the place values starting from the right hand side.
 If a digit is a letter such as ‘A’ write its decimal equivalent
 Multiply each hexadecimal digit with its corresponding place value and then add the products
The binary equivalent of the fractional part is extracted from the products by reading the respective integral digits from the top downwards as shown by the arrow next pag
 The following examples illustrate how to convert hexadecimal number to a decimal numberExample
 Combine the two parts together to set the binary equivalent.
Convert 0.375_{10} into binary form
Read this digits
0.375×2=0.750
0.750×2=1.500
0.500×2=1.000 (fraction becomes zero)
Therefore 0.375_{10}=0.011_{2}
Converting octal numbers to decimal and binary numbers
Converting octal numbers to decimal numbers
 To convert a base 8 number to its decimal equivalent we use the same method as we did with binary numbers. However, it is important to note that the maximum absolute value of a octal digit is 7.For example 982 Is not a valid octal number because digit 9 is not an octal digit, but 736_{8 }is valid because all the digits are in the range 07.Example shows how to convert an octal number to a decimal number.
Example 1.13
Convert 512_{8 }to its base 10 equivalent
Solution
Place value 
8^{2} 
8^{1} 
8^{0}

64 
8 
1 

Octal digit 
5 
1 
2 
Write each number under its place value as shown below
Multiply each number by its place value.
N_{10}=(5 x 8^{2})+(1 x 8^{1 })+(2 x 8^{0 }) =(5 x 64)+8+2 =320+8+2 N_{10}=330_{10}

64 x 5=320
8 x 1= 8
1 x 2=+ 2
330
Therefore512_{8 }=330_{10}
Converting octal numbers to binary numbers
 To convert an octal number to binary, each digit is represented by three binary digits because the maximum octal digit i.e. 7 can be represented with a maximum of seven digits. See table:
Octal digit 
Binary equivalents 
0 
000 
1 
001 
2 
010 
3 
011 
4 
100 
5 
101 
6 
110 
7 
111 
_{}
Nimetön #b724
Example
Convert the hexadecimal number 111_{16 }to its binary equivalent.
Solution
Place each number under its place value.
16^{2}

16^{1}

16^{0}

1

1

1

256 x1= 256
16 x 1 = 16
1 x 1= + 1
273
Therefore 111_{16 }=273_{10}
Example
Convert octal number 321_{8 }to its binary equivalent
Solution
Working from left to the right, each octal number is represented using three digits and then combined we get the final binary equivalent. Therefore:
3=011_{2}
2=010_{2}
1=001_{2}
Combining the three from left to right
3 
2 
1 
011 
010 
001 
321_{8 }=011010001_{2}
Converting binary numbers to hexadecimal numbers
To convert binary numbers to their binary equivalents, simply group the digits of the binary number into groups of four from right to left e.g. 11010001.The next step is to write the hexadecimal equivalent of each group e.g.
1101 D
0001 1
The equivalent of 11010001 is D1H or D1_{16}
Converting hexadecimal numbers to decimal and binary numbers.
Converting hexadecimal numbers to decimal number
To convert hexadecimal number to base 10 equivalent we proceed as follows:
First, write the place values starting from the right hand side.
 If a digit is a letter such as ‘A’ write its decimal equivalent
 Multiply each hexadecimal digit with its corresponding place value and then add the products
 The following examples illustrate how to convert hexadecimal number to a decimal number
Example
Convert the hexadecimal number 111_{16 }to its binary equivalent
Solution
Place each number under its place value.
16^{2}

16^{1}

16^{0}

1

1

1

256 x1= 256
16 x 1 = 16
1 x 1= + 1
273
Therefore 111_{16 }=273_{10}
Converting hexadecimal numbers to binary numbers
 Since F is equivalent to a binary number1111_{2 }the hexadecimal number are therefore represented using4 digits as shown in the table below
Hexadecimal digit 
Decimal equivalent 
Binary equivalent 
00 
00 
0000 
01 
01 
0001 
02 
02 
0010 
03 
03 
0011 
04 
04 
0100 
05 
05 
0101 
06 
06 
0110 
07 
07 
0111 
08 
08 
1000 
09 
09 
1001 
A 
10 
1010 
B 
11 
1011 
C 
12 
1100 
D 
13 
1101 
E 
14 
1110 
F 
15 
1111 
The simplest method of converting a hexadecimal number to binary is to express each hexadecimal digit as a four bit binary digit number and then arranging the group according to their corresponding positions as shown in example
Example 1
Convert 321_{16}
Hexadecimal digit 
3 
2 
1 
Binary equivalent 
0011 
0010 
0001 
Combining the three sets of bits, we get 001100100001_{2}
321_{16} = 001100100001_{2}
Example 2
Convert 5E6_{16} into binary
Hexadecimal digit
5 
E 
6 

Binary equivalent 
0101 
1110 
0110 
5E616 = 010111100110_{2}
Symbolic representation using coding schemes
 In computing, a single character such as a letter, a number or a symbol is represented by a group of bits. The number of bits per character depends on the coding scheme used.
 The most common coding schemes are:
 Binary Coded Decimal (BCD),
 Extended Binary Coded Decimal Interchange Code (EBCDIC) and
 American Standard Code for Information Interchange (ASCII).
Binary Coded Decimal
 Binary Coded Decimal is a 4bit code used to represent numeric data only. For example, a number like 9 can be represented using Binary Coded Decimal as 1001_{2 }.
 Binary Coded Decimal is mostly used in simple electronic devices like calculators and microwaves. This is because it makes it easier to process and display individual numbers on their Liquid Crystal Display (LCD) screens.
 A standard Binary Coded Decimal, an enhanced format of Binary Coded Decimal, is a 6bit representation scheme which can represent nonnumeric characters. This allows 64 characters to be represented. For letter A can be represented as 110001_{2} using standard Binary Coded Decimal
Extended Binary Coded Decimal Interchange code (EBCDIC)
 Extended Binary Coded Decimal Interchange code (EBCDIC) is an 8bit charactercoding scheme used primarily on IBM computers. A total of 256 (2^{8}) characters can be coded using this scheme. For example, the symbolic representation of letter A using Extended Binary Coded Decimal Interchange code is 11000001_{2}.
American standard code for information interchange (ASCII)
 American standard code for information interchange (ASCII) is a 7bit code, which means that only 128 characters i.e. 2^{7} can be represented. However, manufactures have added an eight bit to this coding scheme, which can now provide for 256 characters.
 This 8bit coding scheme is referred to as an 8bit American standard code for information interchange. The symbolic representation of letter A using this scheme is 1000001_{2}..
Binary arithmetic operations
 In mathematics, the four basic arithmetic operations applied on numbers are addition, subtraction, multiplications and division.
 In computers, the same operations are performed inside the central processing unit by the arithmetic and logic unit (ALU). However, the arithmetic and logic unit cannot perform binary subtractions directly. It performs binary subtractions using a process known as For multiplication and division, the arithmetic and logic unit uses a method called shifting before adding the bits.
Representation of signed binary numbers
 In computer technology, there are three common ways of representing a signed binary number.
 Prefixing an extra sign bit to a binary number.
 Using ones compliment.
 Using twos compliment.
Prefixing an extra sign bit to a binary number
 In decimal numbers, a signed number has a prefix “+” for a positive number e.g. +27_{10 }and ““ for a negative number e.g.^{}27
 However, in binary, a negative number may be represented by prefixing a digit 1 to the number while a positive number may be represented by prefixing a digit 0. For example, the 7bit binary equivalent of 127 is 1111111_{2}. To indicate that it is positive, we add an extra bit (0) to the left of the number i.e. (0)1111111_{2}.
 To indicate that it is negative number we add an extra bit (1) i.e. (1)1111111_{2}.
 The problem of using this method is that the zero can be represented in two ways i.e.(0)0000000_{2} and (1)0000000_{2}.
Ones compliment
 The term compliment refers to a part which together with another makes up a whole. For example in geometry two complimentary angle (90^{0}).
 The idea of compliment is used to address the problem of signed numbers i.e. positive and negative.
 In decimal numbers (0 to 9), we talk of nine’s compliment. For example the nines compliment
 Of 9 is 0, that of 5 is 4 while 3 is 6.
 However, in binary numbers, the ones compliment is the bitwise NOT applied to the number. Bitwise NOT is a unary operator (operation on only one operand) that performs logical negation on each bit. For example the bitwise NOT of 1100_{2} is 0011_{2}e.
 0s are negated to 1s while 1s are negated to 0s.
Twos compliment
 Twos compliment, equivalent to tens compliment in decimal numbers, is the most popular way of representing negative numbers in computer systems. The advantages of using this method are:
 There are no two ways of representing a zero as in the case with other two methods.
 Effective addition and subtraction can be done even with numbers that are represented with a sign bit without a need for circuitries to examine the sign of an operand.
 The twos compliment of a number is obtained by getting the ones compliment then adding a 1. For example, to get the twos compliment of a decimal number 45_{10,}
 First convert it to its binary equivalent then find its ones compliment. Add a 1 to ones compliment i.e.
45_{10}=00101101_{2}
Bitwise NOT (00101101) =11010010
Two’s compliment = 11010010_{2}+1_{2}
= 11010011_{2}
Binary addition
The five possible additions in binary are
 0 + 0 = 0
 0+ 1_{2} = 1_{2}
 1_{2} + 0 = 1_{2}
 1_{2} + 1_{2} = 10_{2} (read as 0, carry 1)
 1_{2} + 1_{2} + 1_{2} = 11_{2} (read as 1, carry 1)
Example 1
Find the sum of 111_{2} + 011_{2}
Solution
Arrange the bits vertically. 111
Working from the right to the left, we proceed as follows: + 011
Step 1 1_{2} + 1_{2} = 10_{2}, (write down 0 and carry 1) 1010_{2}
Step 2 1_{2} + 1_{2} + 1_{2} = 11_{2}, (add and carry over digit to 1 + 1 in order to get 1 + 1
+1. From the sum, write down digit one the carry
Forward)
Step 3 1_{2} + 1_{2} + 0_{2} = 10_{2}, (add the carry over digit to 1 + 0 in order to get
1 + 1 + 0.since this is the last step, write down 10)
Therefore 111_{2} + 011_{2} = 1010_{2}
This can be summarized in the table
1^{st} number
1
1
1
2^{nd} number
0
1
1
Carry digit

1
1
sum
10
1
0
Example 2
Add the following binary number
10110_{2}
1011_{2}
+ 111_{2}
Solution
Add the first two numbers and then add the sum to the third number a follows:
Step 1 Step 2
10110_{2} 100001_{2}
+ 1011_{2} + 111_{2}
100001_{2 } 101000_{2 }
Binary subtraction
Direct subtraction
The four possible subtractions in binary are:
 0 – 0 = 0
 1_{2} – 0 = 1_{2}
 1_{2 }– 1_{2 }= 0
 10_{2} – 1_{2} = 1_{2 }( borrow 1 from the next most significant digit to make 0 become 10_{2},
hence 10_{2 }– 1_{2} = 1_{2})
Subraction using ones compliment
The main purpose of using ones compliment in computers is to perform binary subtraction. For example to get the difference in 5 – 3, using the ones compliment, we proceed as follows:
 Rewrite the problem as 5 + (3) to show that he computer binary subtraction by adding the binary equivalent of 5 to ones compliment of 3.
 Convert the absolute value of 3 into 8bits equivalent i.e. 00000011_{2}.
 Take the ones compliment of 00000011_{2}e. 11111100_{2} which is the binary representation of 3_{10}.
 Add the binary equivalent of 5 to ones compliment of 3 i.e.
00000101
+ 11111000
(1)00000001
Subtraction using twos compliments.
Like in ones compliment, the twos compliment of a number is obtained by negating a positive number to is negative counterpart. For example to get the difference in 53, using twos compliment, we proceed as follow:
 rewrite the problem as 5 + (3)
 Convert the absolute value of 3 into 8bit binary equivalent i.e. 00000011.
 Take the ones compliment of 00000011 i.e. 11111100.
 add a 1 to the ones compliment i.e. 11111100 to get 11111101
 add he binary equivalent of 5 to the twos compliment of 3 i.e.
00000101
+ 11111001
(1)00000010 Ignoring the overflow bit, the resulting number is 00000010, which is directly read as a binary equivalent of +2.
Example
Using twos compliment
31_{10 } 17_{10 } in binary form.
Solution
17_{10} in binary 00010001
1’s compliment 11101110
2’s compliment 11101111
31_{10} = 00011111_{2}
00011111 + 11101111 = (1)00001110_{2}