Digital computers store and process information in binary form as digital logic has only two values “1” and “0” or in other words “True or False” or also said as “ON or OFF”. This system is called radix 2. We human generally deal with radix 10 i.e. decimal. As a matter of convenience there are many other representations like Octal (Radix 8), Hexadecimal (Radix 16), Binary coded decimal (BCD), Decimal etc.
Every computer’s CPU has a width measured in terms of bits such as 8 bit CPU, 16 bit CPU, 32 bit CPU etc. Similarly, each memory location can store a fixed number of bits and is called memory width. Given the size of the CPU and Memory, it is for the programmer to handle his data representation. Most of the readers may be knowing that 4 bits form a Nibble, 8 bits form a byte. The word length is defined by the Instruction Set Architecture of the CPU. The word length may be equal to the width of the CPU.
The memory simply stores information as a binary pattern of 1’s and 0’s. It is to be interpreted as what the content of a memory location means. If the CPU is in the Fetch cycle, it interprets the fetched memory content to be instruction and decodes based on Instruction format. In the Execute cycle, the information from memory is considered as data. As a common man using a computer, we think computers handle English or other alphabets, special characters or numbers. A programmer considers memory content to be data types of the programming language he uses. Now recall figure 1.2 and 1.3 of chapter 1 to reinforce your thought that conversion happens from computer user interface to internal representation and storage.
Data Representation in Computers
Information handled by a computer is classified as instruction and data. A broad overview of the internal representation of the information is illustrated in figure 3.1. No matter whether it is data in a numeric or nonnumeric form or integer, everything is internally represented in Binary. It is up to the programmer to handle the interpretation of the binary pattern and this interpretation is called Data Representation. These data representation schemes are all standardized by international organizations.
Choice of Data representation to be used in a computer is decided by
 The number types to be represented (integer, real, signed, unsigned, etc.)
 Range of values likely to be represented (maximum and minimum to be represented)
 The Precision of the numbers i.e. maximum accuracy of representation (floating point single precision, double precision etc)
 If nonnumeric i.e. character, character representation standard to be chosen. ASCII, EBCDIC, UTF are examples of character representation standards.
 The hardware support in terms of word width, instruction.
Before we go into the details, let us take an example of interpretation. Say a byte in Memory has value “0011 0001”. Although there exists a possibility of so many interpretations as in figure 3.2, the program has only one interpretation as decided by the programmer and declared in the program.
Fixed point Number Representation
Fixed point numbers are also known as whole numbers or Integers. The number of bits used in representing the integer also implies the maximum number that can be represented in the system hardware. However for the efficiency of storage and operations, one may choose to represent the integer with one Byte, two Bytes, Four bytes or more. This space allocation is translated from the definition used by the programmer while defining a variable as integer short or long and the Instruction Set Architecture.
In addition to the bit length definition for integers, we also have a choice to represent them as below:
 Unsigned Integer: A positive number including zero can be represented in this format. All the allotted bits are utilised in defining the number. So if one is using 8 bits to represent the unsigned integer, the range of values that can be represented is 28 i.e. “0” to “255”. If 16 bits are used for representing then the range is 216 i.e. “0 to 65535”.
 Signed Integer: In this format negative numbers, zero, and positive numbers can be represented. A sign bit indicates the magnitude direction as positive or negative. There are three possible representations for signed integer and these are Sign Magnitude format, 1’s Compliment format and 2’s Complement format.
Signed Integer – Sign Magnitude format: Most Significant Bit (MSB) is reserved for indicating the direction of the magnitude (value). A “0” on MSB means a positive number and a “1” on MSB means a negative number. If n bits are used for representation, n1 bits indicate the absolute value of the number. Examples for n=8:
Examples for n=8:
0010 1111 = + 47 Decimal (Positive number)
1010 1111 = – 47 Decimal (Negative Number)
0111 1110 = +126 (Positive number)
1111 1110 = 126 (Negative Number)
0000 0000 = + 0 (Postive Number)
1000 0000 = – 0 (Negative Number)
Although this method is easy to understand, Sign Magnitude representation has several shortcomings like
 Zero can be represented in two ways causing redundancy and confusion.
 The total range for magnitude representation is limited to 2n1, although n bits were accounted.
 The separate sign bit makes the addition and subtraction more complicated. Also, comparing two numbers is not straightforward.
Signed Integer – 1’s Complement format: In this format too, MSB is reserved as the sign bit. But the difference is in representing the Magnitude part of the value for negative numbers (magnitude) is inversed and hence called 1’s Complement form. The positive numbers are represented as it is in binary. Let us see some examples to better our understanding.
Examples for n=8:
0010 1111 = + 47 Decimal (Positive number)
1101 0000 = – 47 Decimal (Negative Number)
0111 1110 = +126 (Positive number)
1000 0001 = 126 (Negative Number)
0000 0000 = + 0 (Postive Number)
1111 1111 = – 0 (Negative Number)
Converting a given binary number to its 2’s complement form
Step 1. x = x’ + 1 where x’ is the one’s complement of x.
Step 2 Extend the data width of the number, fill up with sign extension i.e. MSB bit is used to fill the bits.
Example: 47 decimal over 8bit representation
Binary equivalent of + 47 is 0010 1111 Binary equivalent of  47 is 1010 1111 (Sign Magnitude Form) 1's complement equivalent is 1101 0000 2’s complement equivalent is 1101 0001
As you can see zero is not getting represented with redundancy. There is only one way of representing zero. The other problem of the complexity of the arithmetic operation is also eliminated in 2’s complement representation. Subtraction is done as Addition.
More exercises on number conversion are left to the selfinterest of readers.
Floating Point Number system
The maximum number at best represented as a whole number is 2^{n}. In the Scientific world, we do come across numbers like Mass of an Electron is 9.10939 x 1031 Kg. Velocity of light is 2.99792458 x 108 m/s. Imagine to write the number in a piece of paper without exponent and converting into binary for computer representation. Sure you are tired!!. It makes no sense to write a number in non readable form or non processible form. Hence we write such large or small numbers using exponent and mantissa. This is said to be Floating Point representation or real number representation. he real number system could have infinite values between 0 and 1.
Representation in computer
Unlike the two’s complement representation for integer numbers, Floating Point number uses Sign and Magnitude representation for both mantissa and exponent. In the number 9.10939 x 1031, in decimal form, +31 is Exponent, 9.10939 is known as Fraction. Mantissa, Significand and fraction are synonymously used terms. In the computer, the representation is binary and the binary point is not fixed. For example, a number, say, 23.345 can be written as 2.3345 x 101 or 0.23345 x 102 or 2334.5 x 102. The representation 2.3345 x 101 is said to be in normalised form.
Floatingpoint numbers usually use multiple words in memory as we need to allot a sign bit, few bits for exponent and many bits for mantissa. There are standards for such allocation which we will see sooner.
IEEE 754 Floating Point Representation
We have two standards known as Single Precision and Double Precision from IEEE. These standards enable portability among different computers. Figure 3.3 picturizes Single precision while figure 3.4 picturizes double precision. Single Precision uses 32bit format while double precision is 64 bits word length. As the name suggests double precision can represent fractions with larger accuracy. In both the cases, MSB is sign bit for the mantissa part, followed by Exponent and Mantissa. The exponent part has its sign bit.
It is to be noted that in Single Precision, we can represent an exponent in the range 127 to +127. It is possible as a result of arithmetic operations the resulting exponent may not fit in. This situation is called overflow in the case of positive exponent and underflow in the case of negative exponent. The Double Precision format has 11 bits for exponent meaning a number as large as 1023 to 1023 can be represented. The programmer has to make a choice between Single Precision and Double Precision declaration using his knowledge about the data being handled.
The Floating Point operations on the regular CPU is very very slow. Generally, a special purpose CPU known as Coprocessor is used. This Coprocessor works in tandem with the main CPU. The programmer should be using the float declaration only if his data is in real number form. Float declaration is not to be used generously.
Decimal Numbers Representation
Decimal numbers (radix 10) are represented and processed in the system with the support of additional hardware. We deal with numbers in decimal format in everyday life. Some machines implement decimal arithmetic too, like floatingpoint arithmetic hardware. In such a case, the CPU uses decimal numbers in BCD (binary coded decimal) form and does BCD arithmetic operation. BCD operates on radix 10. This hardware operates without conversion to pure binary. It uses a nibble to represent a number in packed BCD form. BCD operations require not only special hardware but also decimal instruction set.
Exceptions and Error Detection
All of us know that when we do arithmetic operations, we get answers which have more digits than the operands (Ex: 8 x 2= 16). This happens in computer arithmetic operations too. When the result size exceeds the allotted size of the variable or the register, it becomes an error and exception. The exception conditions associated with numbers and number operations are Overflow, Underflow, Truncation, Rounding and Multiple Precision. These are detected by the associated hardware in arithmetic Unit. These exceptions apply to both Fixed Point and Floating Point operations. Each of these exceptional conditions has a flag bit assigned in the Processor Status Word (PSW). We may discuss more in detail in the later chapters.
Character Representation
Another data type is nonnumeric and is largely character sets. We use a humanunderstandable character set to communicate with computer i.e. for both input and output. Standard character sets like EBCDIC and ASCII are chosen to represent alphabets, numbers and special characters. Nowadays Unicode standard is also in use for nonEnglish language like Chinese, Hindi, Spanish, etc. These codes are accessible and available on the internet. Interested readers may access and learn more.
Computers represent data
using 0’s and 1’s, also known as binary
numbers. Why do computers use binary notation instead of the more
familiar decimal notation (using digits 09) that people use? Each
digit, whether binary or decimal, must be represented by a voltage in
the computer’s circuitry. It is easy to build circuits that
discriminate between two voltages. We could call these voltages “on”
and “off.” It is much harder, though not impossible, to
build circuits to discriminate reliably among ten different voltages.
Reading

Assessments:

–
1.3.1 Bits and Bytes

Data
Representation Using Binary Digits 
Increasing
Need for Bytes
Data Representation Using Binary Digits
A piece of data, such as an
alphabet letter, may be represented using a sequence of binary
digits 0’s and 1’s. There are several types of codes used to
represent character data. For example, using extended ASCII (America
Standard Code for Information Interchange) code, the alphabet letter
“a” can be represented using a series of eight binary
digits, “01100001.” Each binary digit is called a bit.
And, eight bits is one
byte.
Extended ASCII code uses eight bits (or one byte) to represent input
characters. Below are binary representations of characters in
extended ASCII code.
Figure 1
ASCII code
All data, including audio, visual, and program instruction data can
be represented and stored using a sequence of binary digits, or a
sequence of bytes. Recall that a file is a collection of data. In
some files, the bits of data directly encode individual letters,
numbers, and punctuation symbols that make up words and sentences. In
other files such as an image file, the bits of data need to be
computed in order for them to transform to images that we can
interpret.
Most applications such as Microsoft Word or PowerPoint encode
information in specialized ways that are not readable by humans.
Thus, even though Microsoft Word is often used to edit text, a Word
document cannot be properly displayed by a simple text editor like
Notepad because the document includes information in a format
specific to Microsoft Word. Therefore, it must be opened by Microsoft
Word to be read. Some files have a header section that indicates
which format was used to encode the data in order to allow the
computer to reassemble the binary data back into the humanreadable
form of the document.
Increasing Need for Bytes
In the late 1970s and early 1980s, inexpensive personal computers
were manufactured for the first time, and soon a large consumer
market developed. At first small amounts of memory such as thousands
of bytes were all that was needed to handle the simple spreadsheet
and word processing tasks. But, before long, users wanted software to
allow them to do more tasks such as creating drawings and generating
complex page layouts. As consumer demand grew, computing requirements
also grew. This demand led to new developments that expanded memory
capacities. By the mid 1980s, memory was up to millions of bytes.
Today, office and home computers often have billions of bytes in
memory capacity. Memory for dataintensive systems, such as the
Geographic Information System (GIS), require trillions of bytes.
Below is a chart illustrating the storage capacity over the years
since the 1970s with their associated prefix and abbreviation.
Decade  1970s  1980s  1990s  2000s 
Order of magnitude in Storage capacity  Thousands  Millions  Billions  Trillions 
Prefix  Kilo (10^{3})  Mega (10^{6})  Giga (10^{9})  Tera (10^{12}) 
Abbreviation  K  M  G  T 
In terms of storage, more is better—which means more information in
the form of both data and programs that act on that data can be
stored. Corresponding to the growth in storage capacity, memory
capacity is also increasing. Moreover, memory technologies are
getting smaller, lighter, and faster, for about the same price. You
will learn more about storage and memory technologies in the next
unit of this course.
–
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.
Teksti
 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.
Teksti

 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
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 
Teksti
Example
Convert the hexadecimal number 111_{16 }to its binary equivalent.
Solution
Place each number under its place value.
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
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.
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}
Peda.net käyttää vain välttämättömiä evästeitä istunnon ylläpitämiseen ja anonyymiin tekniseen tilastointiin. Peda.net ei koskaan käytä evästeitä markkinointiin tai kerää yksilöityjä tilastoja. Lisää tietoa evästeistä
A computer uses a fixed number of bits to represent a piece of data which could be a number, a character, image, sound, video, etc. Data representation is the method used internally to represent data in a computer. Let us see how various types of data can be represented in computer memory.
Table of Contents
Before discussing data representation of numbers, let us see what a number system is.
Number Systems
Number systems are the technique to represent numbers in the computer system architecture, every value that you are saving or getting into/from computer memory has a defined number system.
A number is a mathematical object used to count, label, and measure. A number system is a systematic way to represent numbers. The number system we use in our daytoday life is the decimal number system that uses 10 symbols or digits.
The number 289 is pronounced as two hundred and eightynine and it consists of the symbols 2, 8, and 9. Similarly, there are other number systems. Each has its own symbols and method for constructing a number.
A number system has a unique base, which depends upon the number of symbols. The number of symbols used in a number system is called the base or radix of a number system.
Let us discuss some of the number systems. Computer architecture supports the following number systems:
 Binary Number System
 Octal Number System
 Decimal Number System
 Hexadecimal Number System
Binary Number System
A Binary number system has only two digits that are 0 and 1. Every number (value) represents 0 and 1 in this number system. The base of the binary number system is 2 because it has only two digits.
Octal Number System
The octal number system has only eight (8) digits from 0 to 7. Every number (value) represents with 0,1,2,3,4,5,6 and 7 in this number system. The base of the octal number system is 8, because it has only 8 digits.
Decimal Number System
The decimal number system has only ten (10) digits from 0 to 9. Every number (value) represents with 0,1,2,3,4,5,6, 7,8 and 9 in this number system. The base of decimal number system is 10, because it has only 10 digits.
Hexadecimal Number System
A Hexadecimal number system has sixteen (16) alphanumeric values from 0 to 9 and A to F. Every number (value) represents with 0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E and F in this number system. The base of the hexadecimal number system is 16, because it has 16 alphanumeric values.
Here A is 10, B is 11, C is 12, D is 13, E is 14 and F is 15.
Data Representation of Characters
There are different methods to represent characters. Some of them are discussed below:
 ASCII
 EBCDIC
 ISCH
 Unicode
ASCII
The code called ASCII (pronounced ‘’.Skey”), which stands for American Standard Code for Information Interchange, uses 7 bits to represent each character in computer memory. The ASCII representation has been adopted as a standard by the U.S. government and is widely accepted.
A unique integer number is assigned to each character. This number called ASCII code of that character is converted into binary for storing in memory. For example, the ASCII code of A is 65, its binary equivalent in 7bit is 1000001.
Since there are exactly 128 unique combinations of 7 bits, this 7bit code can represent only128 characters. Another version is ASCII8, also called extended ASCII, which uses 8 bits for each character, can represent 256 different characters.
For example, the letter A is represented by 01000001, B by 01000010 and so on. ASCII code is enough to represent all of the standard keyboard characters.
EBCDIC
It stands for Extended Binary Coded Decimal Interchange Code. This is similar to ASCII and is an 8 bit code used in computers manufactured by International Business Machine (IBM). It is capable of encoding 256 characters.
If ASCII coded data is to be used in a computer that uses EBCDIC representation, it is necessary to transform ASCII code to EBCDIC code. Similarly, if EBCDIC coded data is to be used in an ASCII computer, EBCDIC code has to be transformed to ASCII.
ISCH
ISCII stands for Indian Standard Code for Information Interchange or Indian Script Code for Information Interchange. It is an encoding scheme for representing various writing systems of India. ISCII uses 8bits for data representation.
It was evolved by a standardization committee under the Department of Electronics during 198688 and adopted by the Bureau of Indian Standards (BIS). Nowadays ISCII has been replaced by Unicode.
Unicode
Using 8bit ASCII we can represent only 256 characters. This cannot represent all characters of written languages of the world and other symbols. Unicode is developed to resolve this problem. It aims to provide a standard character encoding scheme, which is universal and efficient.
It provides a unique number for every character, no matter what the language and platform be. Unicode originally used 16 bits which can represent up to 65,536 characters. It is maintained by a nonprofit organization called the Unicode Consortium.
The Consortium first published version 1.0.0 in 1991 and continues to develop standards based on that original work. Nowadays Unicode uses more than 16 bits and hence it can represent more characters. Unicode can represent characters in almost all written languages of the world.
Data Representation of Audio, Image and Video
In most cases, we may have to represent and process data other than numbers and characters. This may include audio data, images, and videos. We can see that like numbers and characters, the audio, image, and video data also carry information.
We will see different file formats for storing sound, image, and video.
Multimedia data such as audio, image, and video are stored in different types of files. The variety of file formats is due to the fact that there are quite a few approaches to compressing the data and a number of different ways of packaging the data.
For example, an image is most popularly stored in Joint Picture Experts Group (JPEG ) file format. An image file consists of two parts – header information and image data. Information such as the name of the file, size, modified data, file format, etc. is stored in the header part.
The intensity value of all pixels is stored in the data part of the file. The data can be stored uncompressed or compressed to reduce the file size. Normally, the image data is stored in compressed form. Let us understand what compression is.
Take a simple example of a pure black image of size 400X400 pixels. We can repeat the information black, black, …, black in all 16,0000 (400X400) pixels. This is the uncompressed form, while in the compressed form black is stored only once and information to repeat it 1,60,000 times is also stored.
Numerous such techniques are used to achieve compression. Depending on the application, images are stored in various file formats such as bitmap file format (BMP), Tagged Image File Format (TIFF), Graphics Interchange Format (GIF), Portable (Public) Network Graphic (PNG).
What we said about the header file information and compression is also applicable for audio and video files. Digital audio data can be stored in different file formats like WAV, MP3, MIDI, AIFF, etc. An audio file describes a format, sometimes referred to as the ‘container format’, for storing digital audio data.
For example, WAV file format typically contains uncompressed sound and MP3 files typically contain compressed audio data. The synthesized music data is stored in MIDI(Musical Instrument Digital Interface) files.
Similarly, video is also stored in different files such as AVI (Audio Video Interleave) – a file format designed to store both audio and video data in a standard package that allows synchronous audio with video playback, MP3, JPEG2, WMV, etc.
FAQs About Data Representation in Computer
What is number system with example?
Let us discuss some of the number systems. Computer architecture supports the following number of systems:
1. Binary Number System
2. Octal Number System
3. Decimal Number System
4. Hexadecimal Number System
All modern computer systems store numbers internally using the binary system. As well as numbers,computers need to be able to store and process other information such as text and graphics. Since the computer itself can, at a primitive level, only store numbers, systems had to be developed to represent text and other data numerically.
Numeric Data Representation
In the A/L syllabus we have to learn 4 number systems use by computers.
 Binary Number System
 Octal Number System
 Decimal Number System
 Hexadecimal Number System
Binary Number System
 Binary number system uses the digits 0 and 1.
 The position values go up by a factor of two as you move left(multiplied by two).
 The position values go down by a factor of two as you move right(divided by two).
 Base is 2.
 Minimum number is 0 and maximum number is 1.
Octal Number System
 Base is 8.
 Octal number system uses the digits 0,1,2,3,4,5,6,7.
 Minimum number is 0 and maximum number is 7.
Decimal Number System
 The most commonly used number system used in day to day life.
 Base is 10.
 Decimal number system uses the digits 0,1,2,3,,4,5,6,7,8,9.
 Minimum number is 0 and maximum number is 9.
Hexadecimal Number System
 Base is 16.
 The symbols in the hexadecimal number system uses 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
 Minimum number is 0 and maximum number is F.
Conversion Between Number System
Binary to Decimal
101010
1 0 1 0 1 0
(1*32) + (0*16) + (1*8) + (0*4) + (1*2) + (0*1)
32 + 0 +8 + 0 + 2 + 0
42
Octal to Decimal
322
3 2 2
(3*64) + (2*8) + (2*1)
192 + 16 + 2
210
Hexadecimal to Decimal
A10
A 1 0
(10*256) + (1*16) + (0*1)
2560 + 16 + 0
2576
Decimal to Binary
Decimal to Octal
2980(decimal)=05644(octal)
Otherwise,
 First convert into binary and do follows,
156(decimal)=10011100(binary)
10 011 100
10 =(1*2)+(0*1) =2
011 =(0*4)+(1*2)+(1*1) =3
100 =(1*4)+(0*2)+(0*1) =4
234(octal)
156(decimal)= 234(octal)
Decimal to Hexadecimal
15605605(decimal)= EE1F65(hexadecimal)
Otherwise,
First convert into binary and do follows,
156(decimal)=10011100(binary)
1001 1100
1001 =(1*8) +(0*4)+(0*2)+(1*1) =9
1100 =(1*8) +(1*4)+(0*2)+(0*1) =12(C)
156(decimal) = 9C(hexadecimal)
Basic Arithmetic & Logic Operations
Binary Addition
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 carry 1
10110 + 11000 = 101110
Octal Addition
234 + 220 = 454
127 + 432 = 561
 If addition is equal to 8 answer is 0 and carry 1
 If addition is greater than to 8 answer is addition – 1 and carry 1
Hexadecimal Addition
A10 + 125 = B35
546 + D23 =1269
 f addition is equal to 16 answer is 0 and carry 1
 If addition is greater than to 16 answer is addition – 1 and carry 1
Bitwise Logic Operation
A B ( A` )A NOT A AND B A OR B A XOR B
0 0 1 0 0 0
0 1 1 0 1 1
1 0 0 0 1 1
1 1 0 1 1 0
NOT Operation
10111 => 01000
AND Operation
1100 AND 1110
1100
OR Operation
1100 AND 1110
1110
XOR Operation
1100 XOR 1110
0010
Signed Number Representation
Signed Number representation is use for encode negative numbers in binary.These are methods used to represent signed numbers.
 Sign and magnitude representation
 One’s complement representation
 Two’s complement representation
Sign and magnitude representation
 Least important method of representing negative numbers.
 MSD(Most Significant Digit) is reserved for indicate sign bit.
 Remaining bits of the number indicate absolute number.
Sign bit 0 represent positive numbers.
Sign bit 1 represent negative numbers.
+10 => 0 0001010 10=> 1 0001010
8 bit number can represent values from 127 (11111111) to +127 (01111111)
This method has two values for zero.
00000000 => +0 10000000 => 0
One’s Complement Representation
 First write down number as 8 bit positive number.
 Convert 0s into 1s and 1s into 0s. (NOT Operation)
15 => (+15)= 00001111
11110000
8 bit number can represent values from 127 (1000000) to +127 (01111111)
This method has two values for zero.
00000000 => +0 10000000 => 0
When add to numbers together (One’s complement addition) carry bit added to the result.
(+4) + (1)
(+4) 0000 0100
(+1) 0000 0001
(1) 1111 1110(One’s complement)
(+4) + (1)=> 0000 0100 + 1111 1110 =1 00000010 => 00000010 +1= 00000011
Two’s complement Representation
 First write down number as 8 bit positive number.
 Convert 0s into 1s and 1s into 0s. (NOT Operation)
 Add 1 to the 2nd step.
15 => (+15)= 00001111
11110000 + 00000001 = 11110001
When add to numbers together (One’s complement addition) carry bit is ignored.
Q & A
 Which of the following has the lowest value?
34(8) 67(10) 2D(16) 100011(2) 11011(2)
Convert all numbers into binary form.5th answer has 5 digits and all the other answers have more than 5 digits.(after the conversion into binary ) So lowest value is 5th answer(11011(2))
2.What is the even number?
111(2) 57(8) A3(16) C2(16) 11(10)
If last digit is(LSD) odd ,it is a odd number, Otherwise it is a even number.So answer is 4th. No need to apply conversions.
3.Which one of the following represent the MSD and LSD of 0.025630 respectively?
0 and 3 2 and 3 6 and 2 2 and 6 6 and 0
MSD is a first digit in a number(without 0). LSD is last digit in a number(without 0). So answer is 3rd.(6 and 2)
4.B12(16) + 5CA(16) =
10DC(16) FDC (16) 10DC(8) 1FDC(16) 0DC(16)
Answer is 1st(10DC(16)). 3rd answer is correct but base is incorrect.
5.Hexadecimal equivalent to the octal number 57
1F(16) 2F(16) 57(16) 17(16) 27(16)
Answer is 2nd(2F)
6. 1461(8) – 763(8) =
476(8) 425(8) 415(8) 375(8) 435(8)
answer is 1st (476(8))
7. What is the 2’s complement of 55 and 10?
00110111,00001010 11001000,11110101 11001000,00001010
11001001,00001010 11001001,11110110
10 is a positive number. So it written as binary conversion. (00001010) 55 is a negative odd number. So sign bit is a 1 (because negative number). Last digit should be 1 (because it is a odd number) No need to calculate both numbers. So answer is 4th(11001001,00001010 ).
8. Convert the binary number 1010.11 to decimal
10.5 100.125 10.75 10.375 10.7
1 0 1 0 . 1 1
(8*1) (4*0) (2*1) (1*0) . (0.5*1) (0.25*1)
8 + 2 . 0.5 + 0.25
10.75
Answer is 10.75
9. Equivalent hexadecimal value of 101011101(2)
AE1 13D 13E 12C DA1
Answer is 2nd. (13D) 1 0101 1101 (1 3 D)
10. What will be the answer if 10110 XOR with 10010?
00010 11011 01100 00011 00100
In the XOR,
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
So, answer is 5th (00100)