0% found this document useful (0 votes)
14 views

INFORMATION REPRESENTATION

Uploaded by

taurin 2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

INFORMATION REPRESENTATION

Uploaded by

taurin 2023
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

INFORMATION

REPRESENTATI
ON
NUMBER SYSTEMS
A number system defines how a number can be represented
using distinct symbols. A number can be represented
differently in different systems. For example, the two
numbers (2A)16 and (52)8 both refer to the same
quantity, (42)10 but their representations are different.
This is the same as using the words cheval(French), and
equus(Latin) to refer to the same entity, a horse. We use
symbols(digits) to represent number.
NUMBER SYSTEMS
(CONT…)
There are natural numbers expressed in what can be
described as the denary, decimal or base-10 system of
numbers. Had we learned to count using 0, 1, 2, 3, 4, 5, 6,
7, 8, 9 we would have more clearly understood that the
number system was base-10 because there are 10
individual, distinct symbols or digits available to express a
number. Numbers in this system are called Denary
numbers or more traditionally, decimal numbers
NUMBER SYSTEMS
(CONT…)
When a number is written down the value that it represents is
defined by the place value of the digits in the number. This can
be illustrated by considering the denary number 346 which is
interpreted as shown below.
Place value 102=100 101=10 100=1
Digit 3 4 6
Product of digit and 300 40 6
place value

Use of place values in the representation of a denary number


NUMBER SYSTEMS
(CONT…)

Binary numbers
The binary number system is a base-2 system which uses
just two symbols, 0 and 1. These binary digits are usually
referred to as 'bits'.
As with a denary number, the value of a binary number is
defined by place values. For example see next slide for
the binary number 101110
NUMBER SYSTEMS
(CONT…)
Binary numbers

Place 25=32 24=16 23=8 22=4 21=2 20=1


value
Digit 1 0 1 1 1 0
Product 32 0 8 4 2 0
of digit
and
Use of place values in the representation of a binary number. By
place
adding up the values in the bottom row you can see that the binary
value
number 101110 has a value which is equivalent to denary number
46.
NUMBER SYSTEMS
(CONT…)
All computer technology is engineered with components
that represent or recognize only two states: “on” and “off”.
To match this, all software used by the hardware uses
binary codes which consist of bits. Binary codes are most
often based on the use of one or more groups of eight bits. A
group of eight bits is called a byte.
NUMBER SYSTEMS
(CONT…)
Hexadecimal numbers
These are base-16 numbers where each hexadecimal digit is
represented by one of the following symbols:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. The symbols A through to F
represent the denary values 10 through to 15. The value of
a number is defined by place values. For example see table
below for the hexadecimal number 2A6
NUMBER SYSTEMS
(CONT…)
Hexadecimal numbers
Place value 162=256 161=16 160=1
Digit 2 A 6
Product of digit and place 512 160 6
value
Use of place values in the representation of a hexadecimal
number
Nibble is a group of four bits. A nibble can be represented by
one hexadecimal digit. This means that each byte of binary code
can be written as two hexadecimal digits.
NUMBER SYSTEMS
(CONT…)
Examples of a byte represented by two hexadecimal digits
Binary Hexadecimal Denary
00001010 0A 10
11111111 FF 255
One example when you will see hexadecimal representations of
bytes is when an error has occurred during the execution of
program. A memory dump could be provided which has a
hexadecimal representation of the content of some chosen part of
the memory. Another use is when the bytes contain binary numbers
in the charts that define character code.
NUMBER SYSTEMS
(CONT…)
Converting between binary and denary numbers
To convert a binary number to a denary number the
straightforward method is to sum the individual position
values knowing that the least significant bit represents 20,
the next one 21 and so on. This is illustrated by conversion
of the binary number 11001 as shown in Figure below.
NUMBER SYSTEMS
(CONT…)
Starting from the least significant bit, the denary equivalent
is 1 + 0 + 0 + 8 + 16 = 25.
NUMBER SYSTEMS
(CONT…)
An alternative method is to use the fact that 1 x 16 is equal
to 2 x 8 and so on.
To carry out the conversion you start at the most significant
bit and successively multiply by two and add the result to
the next digit:
NUMBER SYSTEMS
(CONT…)
Converting denary number to binary
When converting a denary number to binary the procedure
is successive division by two with the remainder noted at
each stage. The converted number is then given as the set
of remainders in reverse order. This is illustrated by the
conversion of de nary 246 to binary:
NUMBER SYSTEMS
(CONT…)
Thus the binary equivalent of denary 246 is 11110110. As a
check that the answer is sensible, you should remember that
you are expecting an 8-bit binary number because the largest
denary number that can be represented in seven bits is 2 7- 1
which is 127. Eight bits can represent values from 0 to 2 8 - 1
which is 255.
The maximum value of a binary integer with k digits is Nmax =
2k -1
If k = 5 Nmax = 25 – 1 = 31
NUMBER SYSTEMS
(CONT…)
Converting hexadecimal numbers
To convert a hexadecimal number to binary, each digit is
treated separately and converted into a 4-bit binary
equivalent, remembering that F converts to 1111, E
converts to 1110 and so on. Subsequent conversion of the
resulting binary to denary can then be done if needed.
NUMBER SYSTEMS
(CONT…)
To convert a binary number to hexadecimal you start with the four
least significant bits and convert them to one hexadecimal digit.
You then proceed upwards towards the most significant bit,
successively taking groupings of four bits and converting each
grouping to the corresponding hexadecimal digit.
It is possible to convert a denary number directly to hexadecimal
but it is easier to convert first to binary before completing the
conversion.
NUMBER SYSTEMS
(CONT…)
NUMBERS AND QUANTITIES
The are several different types of numbers within the
denary
Type ofsystem. Example Comments
number
Integer 3 Or 47 A whole number used for
counting
Signed integer -3 or 47 The positive number has an
implied + sign
Fraction 2/3 or Rarely used in computer science
52/17
A number with a -37.85 or The positive number has an
whole number part 2.83 implied + sign
and a fractional
number part
NUMBERS AND
QUANTITIES(Cont…)
If we have a quantity that includes units of measurement, it can be
written in three different ways. For example, a distance could be
written in any one of these three ways:
• 23567m
• 23.567 x 103
• 23.567 km
The second example has an exponential notation to define the
magnitude of the value. The third example has added a prefix to the
unit to define this magnitude we read this as 23.567 kilometers.
NUMBERS AND
QUANTITIES(Cont…)
The “kilo” is an example of a decimal prefix. There are
four decimal prefixes commonly used for large numbers.
Decimal prefix Symbol used Factor applied to the
name value
kilo k 103
mega m 106
giga g 109
tera t 1012
NUMBERS AND
QUANTITIES(Cont…)
Binary prefix
Binary prefix name Symbol used Factor applied to the
value
kibi Ki 210
mebi Mi 220
gibi Gi 230
tebi Ti 240
When a number or a quantity is represented for a person to
read it is best presented with either one denary digit or two
denary digits before the decimal point.
NUMBERS AND
QUANTITIES(Cont…)
If a calculation is to be performed with values quoted with
different magnitude factors there must first be conversions
to ensure all values have the same magnitude factor. For
example if you need to know how many files of size 2.4 MiB
could be stored on a 4 GiB memory stick there should be a
conversion of the GiB value to the corresponding MiB
value. The calculation would be
= 1076
INTERNAL CODING OF
NUMBERS
Coding for integers
Computers have to store integer values for a number of purposes.
Sometimes the requirement is only for an unsigned integer to be
stored . However, in many cases a signed integer is needed where the
coding has to identify whether the number is positive or negative.
Since most digital computers handle both positive and negative
numbers, some means is required for representing the sign of the
number. This is usually done by adding another bit to the number
called a sign bit. This is usually the left most bit also called Most
Significant Bit (MSB)
INTERNAL CODING OF
NUMBERS (CONT…)
There are three widely used systems for representing both
positive and negative numbers.
• Sign and magnitude
• Ones complement
• Two’s complement
In all three systems, the conversion used is to represent
the +(plus) by 0 (zero) and - (minus) by 1(one). So 0 bit is
for positive numbers and 1 for negative number.
INTERNAL CODING OF
NUMBERS (CONT…)
SIGN AND MAGNITUDE REPRESENTATION
If a signed integer is to be represented, the obvious choice
is to use one bit to represent the+ or - sign. The remaining
bits then represent the value. This is referred to as 'sign and
magnitude representation'.
In sign and magnitude representation, is signed number is
represented in the
Sig M A following
G N I form.
T U D E
n
INTERNAL CODING OF
NUMBERS (CONT…)
The sign is used to indicate positive or negative nature
of stored binary number. The magnitude bits are the true
binary equivalent of the decimal value being represented.
Examples: Represent each of the following numbers in
sign and magnitude form +7 and -7
0111 = +7 1111 = -7
INTERNAL CODING OF
NUMBERS (CONT…)
ONES COMPLEMENT
The one's complement of a binary number is defined as the
binary number obtained if each binary digit is individually
subtracted from 1 which, in practice, means that each 0 is
switched to 1 and each 1 switched to 0.
The positive numbers are represented exactly as the sign
and magnitude representation.
Negative numbers have codes starting with a 1 and their
magnitude can be obtained by Complement the code.
INTERNAL CODING OF
NUMBERS (CONT…)
The 1’s complement form of a binary number is obtained
by changing each 0 to a 1 and each 1 to a 0
Example: Representing -9 in 1’s complement forms using
5bits. Since the number is negative it will be represented
in1’s complement form.
01001= 9
10110 = 1’s complement.
INTERNAL CODING OF
NUMBERS (CONT…)
Two’s Complement
Positive numbers are represented exactly as in the sign and
magnitude representation. The bit is 0 followed by the
magnitude expressed in binary positional representation.
The two's complement is defined as the binary number obtained if 1
is added to the one's complement number.
The two’s complement of a binary is formed by adding the 1’s
complement of the number and adding a 1 to the right most bit
position called the least significant bit (LSB)
INTERNAL CODING OF
NUMBERS (CONT…)
In two’s complement representation the left most bit
(also called the sign bit) is given weight or value.
For example, in 8 bits number, the weight of the left
most bit is -128 -(27 ) while the other bits have the usual
positive weights.
Example: 11101001 equal - 23
11101001 = -1*27 + 1*26 + 1*25 + 0*24 + 1*23 + 0*22 +
0*21 + 1*20
= -128 + 64 + 32 + 0 + 8 + 0 + 0 +
1 = -23
INTERNAL CODING OF
NUMBERS (CONT…)
INTERNAL CODING OF
NUMBERS (CONT…)
Tip: If you are converting a negative denary number into two’s
complement you begin by converting the denary value to a
binary value. Then you must not forget to add a leading zero
before taking the two’s complement to convert the positive value
to a negative value.
Exercises
Using a byte to represent each value, carry out the subtraction
of denary 35 from denary 67 using binary arithmetic with two's
complement representations.
BINARY ARITHMETIC
For binary addition, starting at the As an example, the addition of the
least significant position still binary equivalent of denary 14 to the
applies. The rules for the addition binary equivalent of denary 11 can
of binary digits are: be examined
1011
• 0+0=0
+ 1110
• 0+1=1
……………….
• 1+1=0 with a carry of 1
11001
• 1+1+0=0 with a carry of 1
The steps followed from right to left.
• 1+1+1=1 with a carry of 1
BINARY
ARITHMETIC(Cont…)
For subtraction we can first For binary subtraction, starting
consider how this is done for at the least significant position
denary numbers. As for addition still applies. The rules for the
the process starts with the least subtraction of binary digits are:
significant digits and proceeds
right to left. The special feature • 0-0=0
of subtraction is the borrowing of • 0-1=1 after a borrow
a 1 from the next position when
subtracting digit is larger than
• 1-0=1
the digit is being subtracted from. • 1-1=0
INTERNAL CODING OF
NUMBERS (CONT…)
Binary coded decimal (BCD)
One exception to grouping bits in bytes to represent integers is
the binary coded decimal (BCD) scheme. If there is an
application where single denary digits are required to be
stored or transmitted, BCD offers an efficient solution. The
BCD code uses four bits (a nibble) to represent a denary digit.
We consider the simple scheme where the digits are coded as the
binary values from 0000 to 1001. The remaining codes 1010 to
1111 do not have any meaning.
INTERNAL CODING OF
NUMBERS (CONT…)
If a denary number with more than one digit is to be
converted to BCD there has to be a group of four bits for
each denary digit. There are, however, two options for BCD;
the first is to store one BCD code in one byte leaving four
bits unused . The other option is packed BCD where two 4-
bit codes are stored in one byte. Thus, for example, the
denary digits 8503 could be represented by either of the
codes shown in Figure below.
INTERNAL CODING OF
NUMBERS (CONT…)
There are a number of applications where BCD can be used.
The obvious type of application is where denary digits are
to be displayed, for instance on the screen of a calculator
or in a digital time display.
INTERNAL CODING OF
TEXT
ASCII code
If text is to be stored in a computer, it is necessary to have a
coding scheme that provides a unique binary code for each
distinct individual component item of the text. Such a code is
referred to as a character code. There have been three
significant coding schemes used in computing. One of these,
which is only mentioned here in passing, is the EBCDIC
(Extended Binary Coded Decimal Interchange code) code
used by IBM in their computer systems.
INTERNAL CODING OF TEXT
(CONT…)
The scheme which has been used for the longest time is the ASCII
(American Standard Code for Information Interchange) coding
scheme. This is an internationally agreed standard. There are some
variations on ASCII coding schemes but the major one is the 7-bit code.
Table below shows an edited version with just a few of the codes. The
first column contains the binary code which would be stored in one
byte, with the most significant bit set to zero and the remaining bits
representing the character code. The second column presents the
hexadecimal equivalent as an illustration of when it can be useful to
use such a representation .
INTERNAL CODING OF TEXT
(CONT…)
INTERNAL CODING OF TEXT
(CONT…)
The full table shows the 27 (128) different codes available for a 7-bit
code.
There are certain aspects of the coding scheme which you need to
understand.
Firstly, you can see that the majority of the codes are for printing or
graphic characters. However, the first few codes represent non-
printing or control characters. These were introduced to assist in data
transmission or in entering data at a computer terminal. It is fair to say
that these codes have very limited use in the modern computer world
so they need no further consideration.

You might also like