Number System

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 61

Data Representation in Computers

• Since the early days of human civilisation,


people have been using their fingers, sticks, etc.,
for counting things.
• As daily activities became more complex,
numbers became more important in trade,
time, distance and in all other spheres of human
life.
• Ever since people discovered that it was
necessary to count objects, they have been
looking for easier ways of counting.
Data Representation in Computers
• As manual counting had a limited role for carrying
out a simple computing task, computation that was
more complex made humans to depend on the
machines to perform the computing task efficiently
and accurately.
• With the advancement of machines, different
number systems were formed to make the task
simple, accurate and fast.
• These number systems opened a gateway to
overcome complex computation barriers.
Data Representation in Computers
• A number system defines a set of values used
to represent “quantity”. Generally, one talks
about a number of students attending a class
and a number of modules taken by each
student as well as uses numbers to represent
grades achieved by students in tests.
Data Representation in Computers
• Non-Positional Number Systems: In ancient times, people used to count
with their fingers. When fingers became insufficient for counting, stones
and pebbles were used to indicate the values. This method of counting is
called the non-positional number system. It was very difficult to perform
arithmetic operations with such a number system, as it had no symbol
for zero. The most common non-positional number system is the Roman
number system. These systems are often clumsy and it is very difficult to
do calculations for large numbers.
• Positional Number Systems: A positional number system is any system
that requires a finite number of symbols/digits of the system to
represent arbitrarily large numbers. When using these systems, the
execution of numerical calculations becomes simplified because a finite
set of digits are used. The value of each digit in a number is defined not
only by the symbol, but also by the symbol's position. The most popular
positional number system being used today is the decimal number
system.
Base (Radix) of System
• Base is the number of unique digits (including
zero) used to represent numbers in a
positional number systems.
• The word base (or radix) means the quantity
of admissible marks used in a given number
system. The admissible marks are the
characters such as Arabic numerals, Latin
letters or other recognisable marks, which are
used to present the numerical magnitude of a
“quantity.”
Base (Radix) of System
• The decimal number system originated in India. This
number system has 10 as the base and is indicated by a
subscript 10 (decimal number) following the value of
the number. For example, (7592)10 represents a
number (7592) in the base 10 number system. Similarly,
we have number systems with base other than 10. For
example, (214)8 represents a number (214) in the base
8 number system.
Types of Number System
• Traditionally, the two possible states for the binary system are
represented by the digits 0 and 1.
• Long before the introduction of octal and hexadecimal
numbers, programmers used a convenient method of handling
large binary numbers in either 3-bit or 4-bit groupings.
• Later, the actual machine code for the computer instructions
was replaced by mnemonics, which comprised of three to four
letters of the assembly language for a particular CPU. It was
also possible to use more than one base number for writing
instructions/programs in the assembly languages, so
programmers made sure their assemblers could understand
octal, hexadecimal and binary numbers.
• Octal and hexadecimal numbers are more compact than
binary numbers, which a computer understands.
Types of Number System
• Binary Number System
When numbers are represented in a computer's
memory by means of small electrical circuits, a number
system with only two symbols is used. These symbols
are ON or OFF state of the circuit. This system of
representing numbers is known as the binary number
system. Circuits allow electricity to flow or to be
blocked depending on the type of the circuit. A
computer circuit is made up of transistors, which have
only two states, ON and OFF. ON is interpreted as 1,
while OFF as 0.
Types of Number System
• Octal Number System: The octal number
system is a base 8 system, having eight
admissible marks: 0, 1, 2, 3, 4, 5, 6 and 7 with
no 8 or 9 in the system. This system is a
positional notation number system. The octal
number system uses powers of 8 to determine
the number.
Types of Number System
• Hexadecimal Number System: The
hexadecimal number system uses 0–9 and A–F
to represent a number, where A is equivalent
to decimal 10 and the largest hexadecimal
digit F is equivalent to decimal 15. The base
for a hexadecimal number is 16.
Conversion Between Number Bases
(D-B/O/H)
• Converting Decimal to Binary, Octal and Hexadecimal
• The method used for the conversion of a decimal
number into other number systems is often done
using the “remainder” method. This method involves
the following steps:
1. Divide the decimal number by the base of the target
number system. That is, to convert decimal to binary,
divide the decimal number with 2 (the base of the
binary number system), 8 for octal and 16 for
hexadecimal.
Conversion Between Number Bases
(D-B/O/H)
2. Note the remainder separately. In case of
hexadecimal, if the remainder exceeds 9, then
convert the remainder into an equivalent
hexadecimal form; for example, if the remainder
is 10, then note the remainder as A.
3. Continually repeat the process of dividing until
the quotient is zero and keep writing the
remainders after each step of division.
4. Finally, when no more division can occur, write
down the remainders in reverse order.
Conversion Between Number Bases
(D-B)
• Determine the binary equivalent of (36)10.

• Taking remainders in the reverse order, we have


100100. Thus, the binary equivalent of (36) 10 is
(100100)2.
Conversion Between Number Bases
(D-O)
• Determine the octal equivalent of (359)10.
Conversion Between Number Bases
(D-O)

• Thus, the octal equivalent of (359)10 is (547)8.


Conversion Between Number Bases
(D-H)
• Determine the hexadecimal equivalent of
(5112)10.
Conversion Between Number Bases
(D-H)

• Thus, the hexadecimal equivalent of (5112)10 is


(13F8)16.
Decimal fraction to Binary
• Convert 13.6875 to binary fraction
Decimal fraction to Binary
• Find Binary equivalent for each decimal
fraction
- 0.546875
- 0.743
- 32.45
- 28.555
- 7.0202
Decimal fraction to Octal
• Convert decimal number 0.015625 into octal
form.

• Solution:
0.015625 x 8 = 0.125
0.125 x 8 = 1.000
So, 0.015625(base 10) = 0.01(base 8)
Decimal fraction to Octal
• Convert decimal number 7.16 into octal form.

• Solution:
So, 7(base 10) = 7(base 8)

0.16 x 8 = 1.28
0.28 x 8 = 2.24
0.24 x 8 = 1.92
0.92 x 8 = 7.36
0.36 x 8 = 2.88

• So, (7.16)10 = (7.12172...)8


Decimal Fraction to Hexadecimal
• Convert 0.00390625 into hexadecimal

Solution:
0.00390625 x 16 = 0.0625
0.0625 x 16 = 1.000
• So, 0.00390625(base 10) = 0.01(base 16)
Decimal Fraction to Hexadecimal
• Convert decimal number 10.16 into hexadecimal

• Solution:
10(base 10) = A(base 16)

0.16 x 16 = 2.56
0.56 x 16 = 8.96
0.96 x 16 = 15.36
0.36 x 16 = 5.76
0.76 x 16 = 12.16
So, 0.16(base 10) = 0.28F5C...(base 16)

So, (10.16)10 = (A.28F5C...)16


Conversion Between Number Bases
(B/O/H-D)
• Converting Binary, Octal and Hexadecimal to
Decimal
The method used for the conversion of a
binary, octal or hexadecimal number to
decimal number involves each digit of the
binary, octal or hexadecimal number to be
multiplied by its weighted position and then
each of the weighted values is added together
to get the decimal number.
Conversion Between Number Bases
(B-D)
• Determine the decimal equivalent of (11010) 2.

• Sum of weight of all bits = 16 + 8 + 0 + 2 + 0 = 26.


Thus, the decimal equivalent of (11010)2 is (26)10.
Conversion Between Number Bases

• Determine the decimal equivalent of (456)8.


• Determine the decimal equivalent of (B14)16.
Conversion Between Number Bases
(H-D)

• Sum of weight of all bits = 2816 + 16 + 4 =


2836. Thus, the decimal equivalent of
(B14)16 is (2836)10.
Binary Fraction to Decimal
Binary Fraction to Decimal
• Convert the binary number 1001.011 to
decimal
Binary Fraction to Decimal
Binary Fraction to Decimal
• Convert the binary fraction into decimal
 0.101
 10.01
Octal Fraction to Decimal
• Convert octal number 0.01(base 8) into decimal
form.

Solution:
= 0x80 + 0x8-1 + 1x8-2
= 0 + 0 + 0.015625
= 0.015625

0.01(base 8) = 0.015625(base 10)


Octal Fraction to Decimal
• Convert octal number 7.12172(base 8) into decimal form.

• Solution:
= 7x80 + 1x8-1 + 2x8-2 + 1x8-3 + 7x8-4 + 2x8-5
= 7 + 0.125 + 0.03125 + 0.001953125 +
0.001708984375 + 0.00006103515624
= 7.1599...
= 7.16 (approx. value)

7.12172(base 8) = 7.16(base 10) (approx. value)


Hexadecimal fraction to Decimal
• Convert 3B.F to decimal
Conversion Between Number Bases
• Converting Among Binary, Octal and
Hexadecimal
Converting among binary, octal and
hexadecimal can be accomplished easily
without converting to decimal first, as the
base numbers of all three systems (2, 8 and
16, respectively) are powers of 2. Any octal
digit can be written as a group of three binary
digits, while a hexadecimal number will
comprise four binary digits.
Conversion Between Number Bases
(B – O)
• Determine the octal equivalent of (010111)2

• The octal equivalent of (010111)2 is (27)8.


Conversion Between Number Bases
(B-H)
• Determine the hexadecimal equivalent of
(11001011)2.
Conversion Between Number Bases
(B-H)

• The hexadecimal equivalent of (11001011)2 is


(CB)16.
Conversion Between Number Bases
(O-B)
• Determine the binary equivalent of (231)8.
Conversion Between Number Bases
(O-B)

• Thus, the binary equivalent of (231)8 is


(010011001)2.
Conversion Between Number Bases
(H-B)
• Determine the binary equivalent of (5AF)16.
Conversion Between Number Bases
(H-B)

• Thus, the binary equivalent of (5AF)16 is


(010110101111)2.
Binary Fraction to Octal
• Convert 111101.011012 to octal

• Solution:

111101.0110102
75.328
Octal fraction to Binary
• Convert 64.1758 to binary

• Solution:
64.1758
= 110 100 . 001 111 101
= 110100.0011111012
Binary Fraction to Hexadecimal
Binary Fraction to Hexadecimal
• Convert 11110.010112 to hexadecimal
Binary Fraction to Hexadecimal
• Convert 11110.010112 to hexadecimal

Solution:

11110.010112

= 0001 1110 . 0101 1000

= 1E.5816
Hexadecimal fraction to Binary
• Convert 3B25.E to binary
Hexadecimal fraction to Binary
• Convert BA2.23C16 to binary
Hexadecimal fraction to Binary
BA2.23C16

= 1011 1010 0010 . 0010 0011 11002

= 101110100010.0010001111
Conversion Between Number Bases
(O-H)
• The method used for the conversion of an octal
number to hexadecimal number is accomplished by
the following steps:
1 Convert each octal digit to 3-bit binary form.
2 Combine all the 3-bit binary numbers.
3 Segregate the binary numbers into the 4-bit binary
form by starting the first number from the right bit
(LSB) towards the number on the left bit (MSB).
4 Finally, convert these 4-bit blocks into their
respective hexadecimal symbols
Conversion Between Number Bases
(O-H)
• Determine the hexadecimal equivalent of (2327)8.

Combining the 3-bit binary blocks, we have


010011010111.
Conversion Between Number Bases
(O-H)
• Separating the group of binary numbers (from
the left side) into the 4-bit binary number and
by converting these blocks into their
respective hexadecimal symbols, we have

• Thus, the hexadecimal equivalent of (2327)8 is


(4D7)16.
Conversion Between Number Bases
(O-H)

• Convert 10028 to hexadecimal

• The given number is 10028

10028 = (1 * 83)+ (0 * 82) + (0 * 81) + (2 * 80)

=1 * 512 + 0 * 64 + 0 * 8 + 2 * 1

= 512 + 0 + 0+ 2

= 514(decimal number)

Now we convert the above decimal to hexadecimal

16 | 514
16 | 32 --2
2 -- 0

The hexadecimal number is 202

10028 = 20216
Conversion Between Number Bases
(H-O)
• The method used for the conversion of a
hexadecimal number to octal number is the
same as that used for the octal to hexadecimal
conversion, except that each hexadecimal digit
is converted into 4-bit binary form and then
after grouping of all the 4-bit binary blocks, it
is converted into the 3-bit binary form. Finally,
these 3-bit binary forms are converted into
octal symbols.
Conversion Between Number Bases
(H-O)
• Determine the octal equivalent of (2B6)16.
Conversion Between Number Bases
(H-O)

You might also like