Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Number system , computer science

The document discusses number systems, focusing on data representation in computers, including positional and non-positional systems. It explains the decimal, binary, octal, and hexadecimal systems, detailing their bases, symbols, and conversion methods. Additionally, it covers the importance of binary in computing and provides procedures for converting between different number systems.

Uploaded by

messineymar13453
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Number system , computer science

The document discusses number systems, focusing on data representation in computers, including positional and non-positional systems. It explains the decimal, binary, octal, and hexadecimal systems, detailing their bases, symbols, and conversion methods. Additionally, it covers the importance of binary in computing and provides procedures for converting between different number systems.

Uploaded by

messineymar13453
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Lectur Number Systems

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.

• It uses 10 Symbols or digits to represent


numbers.
Non- Positional Number Systems
• Number System uses an additive approach for indicating values.

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

Understand why Understand how Understand how to Understand how to


computers use to convert Base-2 convert Base-8 convert Base-16
binary (Base-2) numbers to Base- numbers to Base- numbers to Base-
numbering. 10 or Base-8. 10 or Base 2. 10, Base 2 or Base-
8.
Octal
Binary Hexadecimal 0,1,2,3,4,5
,6,7
Decimal 0, 1
0,1,2,3,4,5
,6,7,8,9,A,
0,1,2,3,4,5
B,C,D,E
,6,7,8,9
Why Binary Number System ?

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

The ‘ON’ state is Each switch has


represented by 1 two states: ON or
and ‘OFF’ by 0. OFF

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

Number System Base Digits Used Examples

Binary 2 0,1 (11110000)2

Octal 8 0,1,2,3,4,5,6,7 (360)8

Decimal 10 0,1,2,3,4,5,6,7,8,9 (240)10

Hexadecimal 16 0,1,2,3,4,5,6,7,8,9, (F0)16


A,B,C,D,E,F
1. Binary Number System
• A Binary number system uses only two symbols 0 and 1 to form a
number.
• Bi means two.
• The value of the base of binary number system is 2, because it has
only two digits/symbols(0,1).
• It is also called Base-2 number system.
• We use the subscript 2 to indicate that the number is in binary.
e.g., (1101)2, (101010)2, (1101.111)2
• Each digit of a binary number is called a bit.
• A bit stands for Binary digit.
• The binary number system is also a positional number system where
place value of each binary digit is a power of 2(base).
• The right most bit in a binary number is called Least Significant Bit(LSB).

• The left most bit in a binary number is called Most Significant Bit(MSB).

• For fractional numbers, weights are negative powers of 2 (2-2 , 2-1 , …)

• The weighted values for each position are :


25 24 23 22 21 20 2-1 2-2

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

MSB – Most LSB – Least


Significant Bit Significant Bit
Binary to Decimal Conversion
Procedure: Multiply each digit by its weighted position, and add
each of the weighted values together.
Examples:
(1100 1010)2 = 1x 27 + 1x26 + 0x25 + 0x24 + 1x23 + 0x22 +
1x21 + 0x20
= 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0
= 202
(10011)2 = 1x24 + 0x23 + 0x22 + 1x21 + 1x20
= 16 + 0 + 0 + 2 + 1 = 19
Find the decimal equivalent of the following
Binary Number Decimal Equivalent
(000)2
(001)2
(010)2
(011)2
(100)2
(101)2
(110)2
(111)2
Find the decimal equivalent of the following
Binary Number Decimal Equivalent
(000)2 0
(001)2 1
(010)2 2
(011)2 3
(100)2 4
(101)2 5
(110)2 6
(111)2 7
2. Decimal Number System
• The decimal number system involves ten symbols(0,1,…9)
to form a number. Hence its base is 10.
• It is also known as Base-10 number system.

Weight
Base

104 103 102 101 100 10-1 10-2 10-3

10000 1000 100 10 1 0.1 0.01 0.001

left of the decimal point Right of decimal point


25
Example
28
3. Octal Number System
• Octal means eight.
• Octal number system uses eight symbols 0,1,2,3,4,5,6,7 to form
a number.
• Since the base is 8, it is also called Base-8 number system.
• Weight of each digit is a power of 8(80, 81, 82, 83,…)
Octal Placeholders
Number:
2 4 1

“Sixty-
Fours”

“Ones

“Eights”
Placeholder
Name:

Value: 64*2 8*4 1*1

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

Uses 16 Symbols – 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

Decimal Binary Hexadecimal


1 0001 1
9 1001 9
10 1010 A
15 1111 F
16 10000 10
Importance of Octal and Hexadecimal Number Systems
• With octal, the bits are grouped into three(23 =8) and with hexadecimal,
the bits are grouped into four(24 =16) and these groups are replaced
with the respective octal or hexadecimal symbol.
• This conversion process of binary numbers to octal and hexadecimal
number systems and vice versa are very easy.
• This shorthand notation is widely used in the design and operations of
electronic circuits.
NUMBER CONVERSIONS
Converting from one number system to another
• Input data fed to computers and the final output values generated are to
be in decimal form. This is because, decimal numbers are much more
meaningful to us than the numbers expressed in other number systems.
• Hence computer professionals are often required to convert numbers in
other number systems to decimal number system and vice versa.
• There are various methods to convert numbers from one base to
another.
- Method of converting from another base to decimal
- Method of converting from decimal to another base
- Method of converting from one base to another base
Steps to Converting from Another Base to Decimal
Step 1: Determine the column(positional) value of each digit (this
depends on the position of the digit and the base of the
number system).
Step 2: Multiply the obtained column values (in Step 1) by the
digits in the corresponding columns.
Step 3: Sum up the products calculated in Step 2. The total is the
equivalent value in decimal.
Practice Questions
• Convert the following:
1) 110012 = (_________)10
2) 47068 = ?10
3) 1AC16 = ?10
Converting from decimal to another base
(Division – Remainder Technique)
Step 1: Divide the decimal number by the value of a new base.
Step 2: Record the remainder from Step 1 as the rightmost digit(LSD) of the new base
number.
Step 3: Divide the quotient of the previous division by the new base.
Step 4: Record the remainder from Step 3 as the next digit (to the left)of the new base
number.
Repeat steps 3 and 4, recording remainders from right to left, until the quotient
becomes zero in Step 3.
Note that the last remainder, thus obtained, will be the MSD of the new base number.
1. Decimal to Binary Conversion
▪ The method of converting decimal number to binary
number is represented by repeated division.
▪ In this method, the decimal number is successively divided
by 2(binary) and the remainders are recorded.
▪ The binary equivalent is obtained by grouping all the
remainders, with the last remainder being the Most
Significant Bit (MSB) and the first remainder being the
Least Significant Bit (LSB).
▪ In all these cases, the remainders will be either 0 or
1(binary digit).
42
Convert the decimal number 333 to binary.
Conversion Procedure is as follows :

Division Quotient Remainder Binary


333/2 166 1 1
166/2 83 0 01
83/2 41 1 101
41/2 20 1 1101
20/2 10 0 01101
10/2 5 0 001101
5/2 2 1 1001101
2/2 1 0 01001101
1/2 0 1 101001101 43
Find the binary equivalent of the decimal number
25 and 80.

(25)10 = (11001)2 (80)10 = (1010000)2

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

▪ The method of converting decimal number to hexadecimal


number is also by repeated division .
▪ In this method, the number is successively divided by 16 and
the remainders are recorded.
▪ The hexadecimal equivalent is obtained by grouping all the
remainders, with the last remainder being the Most Significant
Digit (MSD) and first remainder being the Least Significant
Digit(LSD).
▪ Remainders will be 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E or F.
Examples
Convert the number (44978)10 to Octal
Division Quotient Remainder Binary

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.

• The table given below helps us to find the powers of 2


5.1 Binary Fraction to Decimal
• A binary fraction number can be converted into its decimal
equivalent by summing up the product of each bit and its weight.
• Weights of binary fractions are negative powers of 2
i.e., (2-1, 2-2, 2-3, ...) for the digits after the binary point.
Example 1:
Some more examples..
6. Octal to Decimal Conversion
• An octal number can be converted into its decimal equivalent
by summing up the product of each octal digit and its weight.
• Weights are some powers of 8 (80, 81, 82, 83, ...).
• Examples:
7. Hexadecimal to Decimal Conversion
• An hexadecimal number can be converted into its decimal
equivalent by summing up the product of each hexadecimal digit
and its weight.
• Weights are powers of 16 (160,161, 162, ...).
• Examples:
8. Octal to Binary Conversion
• An octal number can be converted into binary by converting
each octal digit to its 3-bit binary equivalent.
• Eight possible octal digits and their binary equivalents are
listed in Table shown below:
Examples
9. Hexadecimal to Binary Conversion
• A hexadecimal number can be converted into binary by
converting each hexadecimal digit to its 4-bit binary equivalent.
• Sixteen possible hexadecimal digits and their binary equivalents
are listed in Table(next page).
Examples:

Table showing the 4-


bit binary equivalent
of hexadecimal digits.
10. Binary to Octal Conversion
The steps for converting a binary number into its octal equivalent
are as follows:
1. Grouping binary digits into a group of 3 bits each starting
from right to left.
2. Convert each of these groups into its octal equivalent.
Examples
11. Binary to Hexadecimal Conversion
The steps for converting a binary number into its hexadecimal
equivalent are as follows:
1. Grouping binary digits into a group of 4 bits each starting
from right to left.
2. Convert each of these groups into its hexadecimal equivalent.
Examples
Binary → decimal/hexadecimal/octal conversion

• Conversion from binary to octal/hexadecimal

– Binary: 100111100012

– Octal: 010 | 011 | 110 | 001=23618

– Hex: 0100 | 1111 | 0001=4F116

• Conversion from binary to decimal

– 1012= 1×22 + 0×21 + 1×20 = 510

– 63.48 = 6×81 + 3×80 + 4×8–1 = 51.510

– A116= 10×161 + 1×160 = 16110


12. Octal to Hexadecimal Conversion
• Conversion of an octal number to hexadecimal number is a two
step process.
1. Octal number is first converted into binary.
2. This binary equivalent is then converted into hexadecimal.
Example
13. Hexadecimal to Octal Conversion
• Conversion of an hexadecimal to octal number is a two step
process.
1. Hexadecimal number is first converted into binary.
2. This binary equivalent is then converted into octal.
Example
Practice Questions
• Convert the following
1) 2510 = ?2
2) 4210 = ?2
3) 95210 = ?8
4) 42810 =?16
5) 110112 = ?10
Assignment No.3
1. Find the binary equivalent of (31)10
2. Find the binary equivalent of (12345)10
3. Find the decimal equivalent of (10001)2
4. _________ is the place value of 9 in 29610.
5. Hexadecimal number system uses ______symbols and octal number system uses
________ symbols.
6. Find octal equivalent of the decimal number 55.
7. Define number system. List out any four number systems.
8. Find missing terms in the following series:
a. 1012 , 10102, 11112, ________, ________.
b. 158 , 168, 178, _______, ______.
c. 1816, 1A16, 1C16 , _____, _____.
9. If (X)8 = (101011)2, find X.
10. Find the largest number in the list.
a. (1001)2 b. (A)16 c. (10)8 d. (11)10
11. Binary number system is used for data representation in computer memory. Why?
12. Convert the following decimal numbers into binary equivalent:
a. 25 b. 128 c. 255 d. 19.875 e. 89.25
13. Convert the following binary numbers into decimal equivalent:
a. 10112 b. 1110012 c. 10000012 d. 1001.112 e. 1111.1112
14. Convert the following decimal numbers into octal and hexadecimal numbers
a. 17 b. 75 c. 100 d. 199 e. 256
15. Convert the following binary numbers into octal and hexadecimal
a. 10112 b. 1010012 c. 111000112 d. 1100011102 e. 100000100012
16. Convert the following octal numbers into decimal.
a. 578 b. 1018 c. 778 d. 2458 e. 12058
17. Fill in the blanks:
a) (-------)2 = (AB)16
b) (---D---)16 = (1010_____1000)16
c) 0.2510 = (__________)2
18. If (X)2 – (1010)2 = (1000)2. Find the value of X.
19. Convert the following numbers into other three number systems: a.
1258 b. 98 c. 1011102 d. A2B16
20. If (X)2 =(Y)8 = (Z)16 = (28)10. Find the value of X, Y and Z.
21. Convert the following numbers into other three number systems: a.
7F.116 b. 93.25 c. 207.138 d. 10111011.11012
22. Write down the following numbers in expanded notation
a. (1011.101)2 b. (65356)10 c. (A5F)16 d. (67.4)8 e. (763.452)10
23. Define the term data representation.
24. What do you mean by a number system? List any four number systems.
25. Binary number system is used for data representation in computer memory.
Why?
26. Carry out the following conversions
1) (71F.A)16 into decimal
2) (1011)2 in to decimal
3) (15.625)10 into binary
4) (10110011)2 into octal
Decimal Number BCD
BCD - Binary Coded Decimal
135 0001 0011 0101
987 1001 1000 0111

Binary Coded Decimal (BCD) is is a form of binary encoding process


for converting decimal numbers into their binary equivalents. Here Decimal BCD
each digit in a decimal number is represented in the form of bits (4- Symbols Code
bit/8-bit). Also called 8421 code. 0 0000
1 0001
•It is a fast and efficient system that converts the decimal numbers 2 0010
into binary numbers as compared to the existing binary system. 3 0011
•These are generally used in digital displays where is the manipulation 4 0100
of data is quite a task. 5 0101
6 0110
•Thus BCD plays an important role here because the manipulation is 7 0111
done treating each digit as a separate single sub-circuit. 8 1000
9 1001
Question Set
• How do you convert a number in any non-decimal number
system into its decimal equivalent? Give the stepwise
procedures for both the integer as well as fractional part.
• How to convert a decimal number to other number systems?
• How to convert a number from other bases to decimal number
systems?

You might also like