Data Representation
Computers store and represent data in a coded form that is not easily read or understood by
humans. We will learn about the different numbers that can be employed in computers
Data is all the raw facts and figures that a computer processes by following a set of
instructions called a program.
The way in which data is stored and represented depends on the medium storing it and the
type of data. Generally, there are two types of data - discrete and continuous.
Discrete data is data that can be counted for example, the number of cars in a car park
or the number of people that responded 'yes' or 'no' to a question. It has no value in
between; for example, you cannot say two and a half students are present. That is the
data can only take certain values, and usually comes in the form of whole numbers or
integers.
Continuous data is data that can be measured and can be recorded at many different
points. That is they can take any measured value within in a given range. For
example, the temperature of a liquid can be recorded as 35 degrees Celsius (°C).
However, based on the accuracy of the instrument the temperature may be recorded to
greater levels of accuracy, Such as 32.5 °C or 32.53 °C or 32.534 °C and so on.
A computer consists of a number of two-state (or bistable) devices that process and store
data.
A bistable device is one which can be set to one of two states at any one point in time. An
example of a bistable device could be a light bulb. A light bulb can be either in the 'on' or 'off
state. A circuit can either pass a current or not pass a current through the bulb.
The two states of a bistable device can be represented by the digits 0 and 1. In the case of
the light bulb we can use 0 to represent the bulb being 'on' and 1 to represent it being ' off.
The binary number system, which consists of two digits 0 and 1, is used by computers to
represent the two states. These two binary digits are also known as bits (short for binary
digits).
A single bit can represent one of two values, 0 and 1. A group of two bits can be used to
represent one of four (2^2)
00 01 10 11
Groups a bits together allows us to represent larger numbers and even symbols where
necessary. We will discuss this further in the lesson.
A bit stands for binary digit and is the smallest unit of storage in a computer system
Numbers and Number Systems
Numbers have a variety of uses and are defined as mathematical value used for counting,
measuring or labeling objects as well as performing arithmetic calculations. Numbers can be
represented using different symbols each infer the value of the number and differ between
civilizations in terms of how the values are presented.
A number system can be defined as method of writing to express numbers. It is the
mathematical notation for representing numbers of a given set or range by using digits or
other symbols in a consist manner.
The value of the digit in any number can be determined based on three factors
- The digits
- The position of the digit in the number
- The base of the number system
In a number system the base determines the number of digits that are available. Bases are
typically placed as subscripts such as 3510 , 10102, 1AC16
Thus a base 10 means there are 10 digits that can be used. Think back to primary school why
is the ones position called ones? Why is there tens or even hundred positions?
This all occurs due to the base of the number system we are using. More specifically the
place value of our digit in the number system.
In any number system the place values of the digits are the powers of the base. They are
assigned by starting from the power of 0 on the right increasing towards the left.
Consequently every decimal number can be presented using a place value .
104 103 102 101 100
Tens of Thousands Thousands Hundreds Tens Ones
10*10*10*10 =10 10 * 10 * 10 10 * 10 = 100 10 * 1 = 10 100 = 1
000 =1000
Example 65410
- This number contains a 4 in the ones position a 5 in the tens position and 6 in the
hundreds position
- Alternatively, you would have learned
4 ones
5 tens
6 hundreds
- Each digit multiplied by their place values and summed would give the original value
(6 * 102 )+ (5 * 101 )+ (4* 100)
(6* 100) + (5 * 10) +( 4*1 )
600 + 50 + 4
654
This concept applies to all other number systems and can be used to determine the magnitude
of a number as well as its representation in another number system
There are a variety of number systems. However, we will focus on the four (4) most common
ones.
1. Decimal Numbers
Base 10 number system
Involves 10 digits ( 0-9)
Used in our everyday lives
2. Binary Numbers
Base 2 number system
Involves only two digits (0 and 1)
Used by computers for processing
3. Octal Numbers
Base 8 number system
Involves 8 digits (0-7)
Used extensively in mainframe computers
Less popular as a result of binary and hexadecimal
4. Hexadecimal Numbers
Base 16 number system
Involves 16 digits ( 0-9 and A(10)-F(15))
Used in preference of binary when you have very large numbers to work with
as it can be made compact with hexadecimal
Number Systems Conversion
Decimal to Binary ( Base 10 to Base 2)
Computers typically convert out decimal numbers into binary. This can be done through a
number of techniques but we will look at the most common method.
Example:
1. Convert 3510 to its binary equivalent:
Operatio Quotien Remainde
n t r
35/2 17 1 Read From bottom to top.
17/2 8 1 Write the values left to
8/2 4 0
4/2 2 0
2/2 1 0
½ 0 1
Therefore 3510 in binary is 1000112
You may also write it in long division format ensuring that you note the remainders.
Tips to Remember
1. Always repeat the operations until the quotient is 0
2. Write the remainders from bottom to top then left to right. That is the last digit in your
division must be the first number you write.
3. Add zeros to the front of the binary digit only to make the binary number the required
amount of bits long. Remember 8 bits make a byte. A byte is normally used to
represent binary codes or numbers
Class Work: Convert the decimal numbers to eight bit binary numbers: ( 15 Marks)
a. 9910
b. 6410
c. 3110
d. 12710
e. 6310
f. 3910
g. 5210
h. 4510
i. 510
j. 10110
k. 20510
l. 7710
m. 9310
n. 5010
o. 33310
Answers: [15] Marks Home Work
Binary to Decimal
Referring to our place values from before we apply the same concept to our base 2 system in
order to convert from a binary value to a decimal value; base 2 to base 10
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
For every binary pattern we can over lay the above format and determine the value of the
decimal representation for any binary combination. The below is an example of how to carry
out this computation. The value furthest to the right for any bit pattern will always be the
ones position. This is important to note as this is the least significant bit while the bit furthest
to the right is the most significant bit.
Example: Convert 11000112 to decimal
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 0 0 0 1 1
The zero positions do not directly contribute to the decimal value they however ensure the
magnitude of the representation is maintained. Without the zeros the value we are trying to
represent would be incorrect.
The calculation is as followed
=(1*64) + (1 * 32) + (0*16) +(8*0) + (4* 0) +(2*1) + (1*1)
=64 + 32 + 2 +1
=9910
Binary Addition Rules
0 + 0 = 02
0+1 = 12
1+0=12
1+1 = 102
1+1+1 = 112
Binary Subtraction Rules
1-0 = 0
2-0 = 0
1-1=0
1-1 = 1 ( borrow)
Further examples will be discussed in class sessions.