Number system , computer science
Number system , computer science
e
5&6
Number Systems
• Data representation is the method used internally to represent data in a computer.
• Representation of numbers - Number System
•A Number is a mathematical object used to count, label and measure.
• A number system is a systematic way to represent numbers.
• Two types: Positional and Non-Positional Number Systems
• The number system that we use in our day to
day life is Decimal Number System.
For e.g., In this system, we have symbols such as I for 1, II for 2, III for 3
and so on.
• Symbols represents the value regardless of its position.
• Each symbol represent the same value regardless of its position in a number.
•In order to find a value, one have to count the number of symbols present in
that number.
• Difficult to perform arithmetic operations.
•Hence positional number systems were developed.
Positional Number Systems
•In Positional Number System, there are only a few symbols called digits.
•These symbols represent different values depending on the position they occupy in a
number.
•The main characteristics which determines the value of each digit in such a number are:
1. The digit itself;
2. The position of the digit in the number; and
3. The base of the number system.
The value of the Base is defined as the total number of digits available in the
number system. The first digit is always zero(0). Hence, the maximum value of a
single digit is always equal to one less that the value of the base.
Positional Number Systems
• The weight of a digit depends upon its relative position. Such a number system is
known as Positional Number System.
• All Positional number systems have a base/radix.
• The place value o a digit is some power of this base.
For eg.: Consider two decimal numbers 756 and 365
756 = seven hundred + five tens + six ones (7 x 10 2+ 5 x 101+ 6 x 100 )
365 = three hundred + six tens + five ones (3 x 10 2 + 6 x 10 1 + 5 x 10 0)
Place value(Weight) of 6 in 756 is 100 is Ones(Unit) Place
Classification of Numbers
1 2 3 4
1
The digital computer represents all kinds
of data and information in binary numbers.
2
All computers work with 0’s and 1’s so it is like
learning alphabets before learning English.
3
For convenience, people use other bases and we need
to know how to convert from one to another.
Computers are
made of a series of
switches
Binary number
system includes
only one and zeros
ON State 1
OFF State 0
Definitions
Number Systems
Base or Radix
A number system in defined as a systematic
way to represent numbers. It is the method The total number of digits used in a number
or system of numbering and representing of system is called its base or radix. OR,
digits in the computer. In other words, A Number of symbols used to represent any
number system defines how a number can be quantity in the system.
represented using distinct symbols.
Positional Values
Bit
For every digit in any number system, we
have a weight associated with it which is A bit (short for "binary digit") is the smallest
called as Positional values. unit of measurement used to quantify
The weight of a digit depends on its relative computer data. It contains a single binary
position in the number. value of 0 or 1.
All positional number systems have a BASE
and the place value of a digit (weight) is
some power of this base.
Octal
Binary Symbols
Hexadecimal used:
Decimal Symbols 0,1,2,3,4,
Symbols used:
Symbols used: 0, 1 5,6,7
0,1,2,3,4,5,6,7,
used:
8,9,
0,1,2,3,4, Base 8
A,B,C,D,E,F
5,6,7,8,9
Base 2
Base 10 Base 16
The base is written after the number as subscript.
56 to
1000110
(1000110)2 base of (56)10
base 2
10
71
(71)8
base 8
The table below shows the sample representations
• The left most bit in a binary number is called Most Significant Bit(MSB).
32 16 8 4 2 1 0.5 0.25
19
Consider the binary number (1101)2
Weight /Place 23 22 21 20
Value
Binary Number 1 1 0 1
(1101)2 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20
= 1 x 8 + 1 x 4 + 0 x 2 + 1x 1
= 8+4+0+1
= 13
So, the decimal equivalent of the binary number (1101) 2 is 13.
1010101111111
Weight
Base
“Sixty-
Fours”
“Ones
”
“Eights”
Placeholder
Name:
Exponential
Expression: 82*2 81*4 80*1
30
Octal Number System
• Computer scientists are often looking for shortcuts to do
things.
• One of the ways in which we can represent binary numbers is
to use their octal equivalents instead.
• This is especially helpful when we have to do fairly
complicated tasks using numbers.
• The octal numbering system includes eight base digits (0-7)
• After 7, the next placeholder to the right begins with a “1”
• 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13 ...
31
4. 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 hexadecimal number system is 16, because it has 16
alphanumeric values. Hence it is also known as Base-16 number
system.
• Here, we have 0 to 9, representing 0 – 9 but from 10, we have A is
10, B is 11, C is 12, D is 13, E is 14 and F is 15.
• Some examples are: (2F15)16, (AF)16 ,(ABC)16,
Hexadecimal Number System
Hexadecimal Number System
Note: Binary equivalent of an odd decimal number ends with 1 and that of an even decimal number ends with 0.
** Converting Decimal Fraction to Binary
▪ To convert a fractional decimal number to binary, we use the
method of repeated multiplication by 2.
▪ At first the decimal fraction is multiplied by 2.
▪ The integer part of the answer will be the MSB of binary
fraction.
▪ Again the fractional part of the answer is multiplied by 2 to
obtain the next significant bit of binary fraction.
▪ The procedure is continued till the fractional part of product is
zero or a desired precision is obtained.
Examples
Convert the given decimal fraction
(0.6875) to its binary equivalent.
48
2. Decimal to Octal Conversion
▪ The method of converting decimal number to octal
number is also by repeated division.
▪ In this method the number is successively divided by 8 and
the remainders are recorded.
▪ The octal equivalent is obtained by grouping all the
remainders, with the last remainder being the MSD and
first remainder being the LSD.
▪ Remainders will be either 0, 1, 2, 3, 4, 5, 6 or 7.
49
Decimal to Octal Conversion -Example
More Examples
3. Decimal to Hexadecimal conversion
44978 / 8 5622 2 2
5622 / 8 702 6 62
702/8 87 6 662
87/8 10 7 7662
10/8 1 2 27662
1/8 0 1 127662
(44978)10 = (127662)8
5. Binary to Decimal conversion
• A binary number can be converted into its decimal equivalent
by summing up the product of each bit and its weight.
• Weights are some power of 2. (20 , 21 , 22 , 23 , ...)
• For example: Convert (11011)2 to decimal.
• Convert (1100010)2 to decimal.
– Binary: 100111100012