010.data Representation
010.data Representation
· Introduction
· Amplitude (A)
· Frequency (f)
· Bits
· Byte
· A Nibble
· Word
· Binary Addition
· Binary Subtraction
Introduction
Hybrid computers, on the other hand can process both discrete and continuous data.
In digital computers, the user input is first converted and transmitted as electrical pulses that can be
represented by two distinct digits' l' and '0' before processing.
Although two graphs can look different in their appearance, they may repeat themselves at equal time
intervals.
Generally, a periodic wave representing a signal can be described using the following parameters.
· Amplitude (A)
· Frequency (f)
Amplitude (A)
Frequency (f):
Frequency of a wave is the number of cycles made by the wave in one second.
The time taken by a signal to complete one cycle is called periodic time.
Periodic time, T, 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. e-mail, it has to be converted to
analog signal.
Since digital computers are the most widely used, this notes seeks to explain in details how data is
represented in digital form.
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
machine readable form i.e. binary form.
Due to this reason, it is important to understand how a computer together with its peripheral devices
handle data in its electronic circuits, on magnetic media arid in optical devices.
Electronics components, such as the microprocessor, are made up of millions of electronic circuits.
The availability of a high voltage (on) in these circuits is interpreted as 'I' while a low voltage (off) is
interpreted as a '0'.
When the switch is closed, the high voltage in the circuit causes the bulb to light (' l' state).
On the other hand, when the switch is open, the bulb goes off ('0' state).
The presence of a magnetic field in one direction on magnetic media is interpreted as 'I', while the field
in the opposite direction is interpreted as '0'.
Magnetic technology is mostly used on storage devices which 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.
The figure below shows how data is recorded on the surface of a magnetic disk. Note that the dipoles on
the track are arranged in groups facing opposite directions.
If the shiny surface is placed under a powerful microscope, the surface can be observed to have very tiny
holes called pits.
The laser beam reflects from the land which is interpreted as '1' while in Figure 1.5 (b) the laser beam
enters a 'pit' and 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.
1. It has proved difficult to develop devices that can understand or process natural language
directly due to the complexity of natural languages.
It is, however, possible to develop devices that can understand binary language.
Devices that read, process and output data in digital form are used in computers and other digital
devices such as calculators.
Binary logic has therefore simplified the technology needed to develop both hardware and software
systems.
2. Other reasons for the use of binary are that digital devices are more reliable, small in size and
use less energy as compared to analog devices.
The terms bits, bytes, nibble and word are used widely in reference to computer memory and data size.
Bits:
A Nibble:
Word
The term word length is used as a 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.
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 into manageable form.
This helps to improve the processing speed and optimise memory usage.
As far as computers are concerned, number systems can be classified into four major categories:
The term decimal is derived from a Latin prefix deci which means ten.
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.
· Absolute 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 an number refers to the position of the digit in that number i.e. whether
"tens", "hundreds", "thousands" etc. as shown in the Table below.
7 4 5 8
The total value of a number is the sum of the place value of each digit making the number. For example,
the total value of the digits can be worked out by as shown below:
7 x 1000 = 7 000
4 x 100 = 400
5 x 10 = 50
8x1=8
Total = 7458
The base value of a number also known as the radix, depends on the type of number system that is
being used. The value of any number depends on the radix. For example the number 10010 is not
equivalent to 1002.
Unlike in decimal numbers where the place values go up in factors of ten, in binary system, the place
values increase by factors of two.
The right most digit has a place value of 1 x 2° while the left most has a place value of 1 x 23 as shown.
Binary digit 1 0 1 1
1 x 8 = 8, 0 x 4 = 0, 1 x 2 = 2, 1 x 1 =1, Total = 11
The place value of octal numbers go up in factors of eight from right to left as shown.
Octal digit 7 2 4 5
This is a base sixteen number system that consist of sixteen digits ranging from 0 - 9 and letters A - F
where A is equivalent to 10, B to 11 up to F which is equivalent to 15 in base ten system.
Hexadecimal digit 9 4 6
Base 10 0 1 2 3 4 5 6 7 8 9 10
11 12 13 14 15
Base 16 0 1 2 3 4 5 6 7 8 9 A
B C D E F
A hexadecimal number is usually denoted using 16 as a subscript or capital letter H to the right of the
number.
So far, we have looked at the four types of number systems and introduced their basic concepts in a
general and limited way.
However, in this section, we shall have a detailed look at how to convert numbers from one system to
another.
First write the place values starting from the right hand side.
Add up the products. The answer will be the decimal number in base 10.
To convert a decimal number to binary, there are two possible methods, the long division method and
the place value method.
However, at each level of the division, the remainder which is either a 1 or 0 is written to the right of the
quotient.
Starting from bottom upwards, read the series of the remainder digits.
The series of 1 's and O's obtained represent the binary equivalent of the number.
To convert a decimal number to a binary number using place value method proceed as follows:
Write down the place values in factors of 2 up to the value immediately larger or equal to the number
being considered.
For example, to convert 24710 into binary, we write" down the place values up to 28 i.e.256.
Similarly to convert 25810' write down the place values up to 29 i.e. 512.
If the number being considered is itself a factor of 2 such as 64, 128, 256 etc., then place values should
be written up to the number itself.
Starting from the left as shown in the table below, subtract the place value from the number being
converted.
In the table below, a 0 is placed in the binary digits row of the first column because 247 - 256 gives a
negative value.
The number 247 is then carried forward to the next lower place value i.e. 128.
Place value 28 27 26 25 24 23 22 21 2o
Binary digit 0
Since 247 - 128 gives a positive difference of 119, the digit 1 is placed in the second column of the binary
digit row and the difference is carried forward to the next lower place value as shown.
128
64
32
16
Binary digit 0 1
256
128 64
32
16
0 1 1 1 1
8 4 2 1
7-8 7-4 3-2 1-1= 0
0 1 1 1
A decimal number which has both an integral and fractional part is called a real number.
The weight of the integral part of a real number increases from right to left in factors of 10 while that of
the fractional part decreases from left to right in factors of 10-x.
Table below shows how a real number 87.537 can be represented using the place values.
Decimal digit 8 7 . 5 3 7
For a binary number, the same approach as in the example above can be used, only that the place values
(weight) are based on factors of 2. For example, the binary number 11.110112 can be represented as
shown in the table below.
Binary digit 1 1 . 1 1 0 1 1
NB: When converting a real number from binary to decimal, work out the integral and fractional parts
separately then combine them.
Remember that to convert a decimal integer to its binary equivalent we continuously divide the number
by 2.
However to convert the fractional part to its binary equivalent, we 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 repeating the
value of the original fractional part of the number being converted:
The binary equivalent of the fractional part is extracted from the products by reading the respective
integral digits from the top downwards.
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 an octal digit is 7.
For example 982 is not a valid octal number because digits 8 and 9 are not octal digits, but 7368 is valid
because all the digits are in the range of 0 - 7.
Example
Solution
82 81 80
64 8 1
2 7 5
= 128 + 56 + 5 = 189
To convert an octal number to binary, each digit is represented by 3 binary digits because the maximum
octal digit i.e. 7 can be represented with a maximum of 3 digits.
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
Example
= (540)8
= (101100000)2
Multiply each hexadecimal digit with its corresponding place value and then add the products.
Example
= (ABCDEF)16
= (10x165+11x164+12x163+13x162+14x161+15x160)10
= (10485760+720896+49152+3328+224+15)10
= (11259375)10
Since F is equivalent to a binary number 11112, the hexadecimal numbers are represented using 4 digits
as shown.
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 number and then arranging the groups according to their corresponding positions as
shown.
00111011001010012
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 the Binary Coded Decimal (BCD), Extended Binary Coded Decimal
Interchange Code (EBCDIC) and American Standard Code for Information Interchange (ASCII).
Binary Coded Decimal is a 4-bit code used to represent numeric data only.
For example, a number like 9 can be represented using Binary Coded Decimal as 10012, Binary Coded
Decimal system 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 6-bit
representation scheme which can represent nonnumeric characters.
For example, letter A can be represented as 1100012 using the standard Binary Coded Decimal.
Extended Binary Coded Decimal Interchange Code (EBCDIC) is an 8bit character coding scheme used
primarily on IBM computers.
For example, the symbolic representation of letter A using Extended Binary Coded Decimal Interchange
Code is 110000012,
American Standard Code for Information Interchange (ASCII) is a 7-bit code, which means that only 128
characters i.e. 27 can be represented.
However manufacturers have added an eighth bit to this coding scheme, which can now provide for 256
characters.
This 8-bit coding scheme is referred to as an 8-bit American Standard Code for Information Interchange.
In mathematics, the four basic arithmetic operations applied on numbers are addition, subtraction,
multiplication 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 subtraction directly.
For multiplication and division, the arithmetic and logic unit uses a method called shifting before adding
the bits; however, because the treatment of this method is beyond the scope of this book, we shall only
explain how the computer performs binary addition and subtraction.
Representation of Signed Binary Numbers
In computer technology there are three common ways of representing a signed binary number.
In decimal numbers, a signed number has a prefix "+" for a positive number e.g. +2710 and "-" for a
negative number e.g. -2710
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 7-bit binary equivalent of 127 is 11111112, To indicate that it is positive, we add an
extra bit (0) to the left of the number i.e. (0)11111112, To indicate that it is a negative number we add an
extra bit (1) i.e. (1)11111112,
The problem of using this method is that the zero can be represented in two ways i.e. (0)00000002 and
(1 )00000002,
Ones complement
The term complement refers to a part which together with another makes up a whole.
For example in geometry two complementary angles add up to one right angle (90°).
The idea of complement is used to address the problem of signed numbers i.e., positive and negative.
However, in binary numbers, the ones complement 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 11002 is 00112 i.e. 0s are negated to 1s while 1's are negated to 0’s.
Like in the method of using an extra sign bit, in ones complement, there are two ways of representing a
zero.
Twos complement
Twos complement, equivalent to tens complement in decimal numbers, is the most popular way of
representing negative numbers in computer systems.
There are no two ways of representing a zero, as is the case with the other two methods.
Effective addition and subtraction can be done even with numbers that are represented with a sign bit
without a need for extra circuitries to examine the sign of an operand.
The twos complement of a number is obtained by getting the ones complement then adding a 1.
For example, to get the twos complement of a decimal number 4510' first convert it to its binary
equivalent then find its ones complement.
4510 = 001011012
Binary Addition
0+0=0
0 + 12= 12
12 + 0 = 12
Binary Subtraction
Direct subtraction
0-0=0
12-0= 12
12 - 12 = 0
102 - 12 = 12 (Borrow 1 from the next most significant digit to make 0 become 102, hence 102 - 12 = 12)
The main purpose of using the ones complement in computers is to perform binary subtractions.
For example to get the difference in 5 - 3, using the ones complement, we proceed as follows:
Rewrite the problem as 5 + (-3) to show that the computer performs binary subtraction by adding the
binary equivalent of 5 to the ones complement of 3.
Take the ones complement of 000000 112 i.e. 111111002 which is the binary representation of -310'
000000101
+111111000
(1)00000001
Looking at the difference of the two binary numbers, you will observe that:
The result show that the difference between the two numbers is 00000001. This is not true! We know
that it should be 00000010.
To address this problem in a system that uses ones complement, the overflow digit is added back to the
magnitude of the 8-bit difference.
Therefore the difference becomes 00000001 + 1 = 00000010, which is the correct answer.
For example to get the difference in 5 - 3, using the two's complement, we proceed as follows:
Convert the absolute value of 3 into 8-bit binary equivalent i.e. 00000011.
000000101
+111111001
(1)00000010
Ignoring the overflow bit, the resulting number is 00000010 which is directly read as a binary equivalent
of +2.