0% found this document useful (0 votes)
20 views18 pages

Number Systems: Base/radix of A Number System

C++

Uploaded by

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

Number Systems: Base/radix of A Number System

C++

Uploaded by

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

1

St.Antony’s college, peruvanthanam

MODULE 3
NUMBER SYSTEMS
A Number System is a way to represent numbers. There are two types of
number systems

➢ Non-positional number systems


➢ Positional number systems

Non-positional number systems

In this method, we use symbols for counting such as I for 1,II for 2,III for
3……etc. These are also position invariant. That means the symbols are position
independent. They have no values depending on their position and are not used for
arithmetic calculations

Positional number systems

In positional number systems we use digits for counting. These digits represent
different values depending on the position they occupy in the number. The value of
each digit in a number is determined using three factors

1. The digit itself


2. The position of the digit in the number
3. The base of number system

Example: 423

The value of each digit is

3*100 = 3*1 = 3
2*101 = 2*10= 20 3+20+400 = 423(which is the real number)
4*102 = 4*100 =400
Base/radix of a number system
Base of a number system is defined as the total number of digits available in that
number system. Numbers are always starting with 0.The maximum value of a
number system is equal to one less than the base of that number system.

Base of decimal number system is 10


Department of computer science BCA
2
St.Antony’s college, peruvanthanam
Base of binary number system is 2 Base
of octal number system is 8
Base of hexa decimal number system is 16

Different types of positional number system [popularly used


number system]

➢ Decimal number system


➢ Binary number system
➢ Octal number system
➢ Hexa-decimal number system

Decimal number system

It is also called denary number system or Arabic number system. It has two parts,
Integer part & fractional part. Both are separated by a decimal point. Base of
decimal number system is 10. Each position to the left of decimal point is
represented as the power of base 10. Each position to the right of decimal point is
represented as the negative power of base 10.
Eg:234.78

Binary number system


It consists of two digits,0 and 1. Base of binary number system is 2. Each position
in a binary number is represented as the power of base 2.
Eg: 11100

Department of computer science BCA


3
St.Antony’s college, peruvanthanam

Octal number system


The digits in this number system are 0-7. Base of octal number system is 8.
Each position in an octal number is represented as the power of base 8

Eg:1452

Hexa-decimal Number system


The digits in this number system are 0-9 and A-F. The

value of A=10, B=11,C=12,D=13,E=14,F=15

Base of hexa-decimal number system is 16. Each position in a hexa-decimal


number is represented as the power of base 16

Eg:14FA2

NUMBER CONVERSION
I.
1. Binary to decimal

Method: To convert a binary number to a decimal number, multiply each


binary digit with its weight and calculate the sum of products

➢ Rightmost bit in a binary number is called Least Significant bit(LSB).it has


always the weight 20
➢ Leftmost bit in a binary number is called Most Significant bit(MSB)
Example:

(1110)2 = ( ? )10

(1110)2 = 0*20 + 1*21 +1*22 +1*23

=0+2+4+8

=(14)10

Department of computer science BCA


4
St.Antony’s college, peruvanthanam

➢ All the bits to the right of decimal point have the weight that are negative
powers of base 2

Example:

(.010)2 = ( ? )10

(.010)2 = 0*2-1 +1*2-2 +0*2-3

= 0+ .25 +0

=(.25)10

2. Binary to Octal.

Method: To convert a binary number to an octal number, break the binary


number beginning at the decimal point into group of 3 bits and convert
each group into appropriate octal number by using 8421 method

Example:
(101110.011)2 = ( ? )8

(101110.011)2 =

101 110.011 421


5 6 . 3 1 01

=(56.3)8 110

011

Department of computer science BCA


5
St.Antony’s college, peruvanthanam

3. Binary to Hexa-decimal.

Method: To convert a binary number to a hexa-decimal number, break the


binary number beginning at the decimal point into group of 4 bits and convert
each group into appropriate hexa-decimall number by using 8421 method

Example:

(1101011.1101)2 = ( ? )16 8421`

= 0 1 1 0 1 0 1 1. 1101 0110

6 B . D 1011->11(B)

=(6B . D)16 1101->13(D)

II.

1. Decimal to Binary

Method:

➢ The method of converting decimal number to a binary number is called


Repeated division by 2
➢ We divide the decimal number by the base of binary number until there is a
0 quotient
➢ The first reminder to be produced is the LSB of binary number
➢ The last remainder to be produced is the MSB of binary number

Department of computer science BCA


6
St.Antony’s college, peruvanthanam

Example

(25)10 ( ? )2

=(11001)2

➢ To convert decimal fractions into binary number, use the method repeated
multiplication by 2 method
Example: (.3125)10 = ( ? )2

= ( .0101)2

Department of computer science BCA


7
St.Antony’s college, peruvanthanam

2. Decimal to Octal

Method:

➢ The method of converting decimal number to a octal number is called


Repeated division by 8
➢ We divide the decimal number by the base of octal number until there is a
0 quotient
➢ The reminders generated by each division form the octal number
Example:

(569)10 = ( ? )8

➢ To convert decimal fraction to octal use the method repeated


multiplication by 8

Department of computer science BCA


8
St.Antony’s college, peruvanthanam

3. Decimal to Hexa-decimal

Method:

➢ The method of converting decimal number to a hexa-decimal number is


called Repeated division by 16
➢ We divide the decimal number by the base of hexa-decimal number until
there is a 0 quotient
➢ The reminders generated by each division form the hexa-decimal number
Example:
(2545)10 =( ? )16

=(9F1)16

➢ To convert decimal fraction to hexa-decimal use the method repeated


multiplication by 16
Example:
(.3725)10 =(?)16

.3725 * 16 = 5. 96
.96 * 16 = 15.36
.36 * 16 = 5.76
.76 * 16 = 12.16
=(5F5C)16

Department of computer science BCA


9
St.Antony’s college, peruvanthanam

III.
1. Octal to Binary
To convert octal numbers to corresponding binary number, simply replace
each octal digit into the 3 bit binary number and combine the results.

Example:

(436)8 = (?)2

4 3 6

100 011 110

=( 100011110)2

2. Octal to Decimal
• To convert octal numbers to corresponding decimal number, multiply
each octal digit with its weight and calculate the sum of products
• All the bits to the right of decimal point have the weight that are negative
powers of base 8
Example

(547.14)8 = ( ? )10

(547)8

=7*80+ 4*81 +5*82

=7+32+320

=(359)10

(.14)8

=1*8-1 + 4*8-2

=(1*.125)+(4*.015)

Department of computer science BCA


10
St.Antony’s college, peruvanthanam

=.125+.06

=(.185)10

Answer=(359.185)10

3. Octal to Hexa-Decimal
❖ There is no methods to convert octal number to hexa-decimal directly
❖ So we first convert the octal number to corresponding binary number and
then convert the binary number to its equivalent hexa-decimal number
Ie.

Octal number

Binarynumber

Hexa-decimal number

Example:

(345)8 = (?)16

3 4 5

011 100 101

Binary number 011100101

0000 1 1 1 0 0 1 0 1

0 14(E) 5

=(E5)16

Department of computer science BCA


11
St.Antony’s college, peruvanthanam

IV.
1. Hexa-decimal to binary
Method:To convert Hexa-decimal numbers to corresponding binary number,
simply replace each Hexa-decimal into the 4 bit binary number and combine
the results.

Example:
(AF13)16 =(? )2 8421
1010(A)
1111(F)
0001
0011
A F 1 3

1010 1111 0001 0011


=(1010111100010011)2

2. Hexa-decimal to Decimal
Method: To convert hexa-decimal numbers to corresponding decimal
number, multiply each hexa-decimal digit with its weight and calculate the
sum of products
Example:
(B2F8)16 =( ?)10
=8*160 + F*161 + 2*162 + B*163
=8*160 + 15*161 + 2*162 + 11*163
=8+240+512+45056
=(45816)10
3. Hexa-decimal to Octal
❖ There is no methods to convert hexa-decimal number to octal directly
❖ So we first convert the hexa-decimal number to corresponding binary
number and then convert the binary number to its equivalent octal
number

Department of computer science BCA


12
St.Antony’s college, peruvanthanam

Ie.

hexa-decimal number

Binarynumber

Octal number

Example:

(E5)16 =(?)8

=E 5

1110 0101

Binary number 11100101

= 0 1 1 1 0 0 1 0 1
3 4 5
=(345)8

Arithmetic Addition

Rules for addition


0+0=0
1+0=1
0+1=1
1+1=10(zero with carry one)

Department of computer science BCA


13
St.Antony’s college, peruvanthanam

Example:1
00111+10101= ?

Answer=11100

Example:2
11101+11011=?

Answer=111000

1’s Complement of Binary Number


The 1’s complement of binary number is formed by changing all 1’s to 0s
and all 0’s to 1’s.
Example: 1’s complement of 1010 =0101
2’s Complement of Binary Number
The 2’s complement of binary number is formed by adding 1 to the 1’s
complement of that binary number
Example: 2’s complement of 1011= 0100 +1 =0101

Department of computer science BCA


14
St.Antony’s college, peruvanthanam

Applications of 1’s complement and 2’s complement

Applications of 1’s complement


We can use the 1’s complement method for the subtraction of binary
numbers. We can subtract binary numbers by using 1’s complement
through addition

I. Subtract smaller number from Larger number

Step1: Determine the 1’s complement of second number

Step2: Add this1’s complement to the first number

Step3: remove the carry and add it to the result. This carry is called end
around carry

Example:

11001-10011 =?

Step1: 1’s complement =01100

Step2: Add 11001 +

01100

100101

Step 3: Remove the carry and add it to the result

00101 +

00110

11001-10011= 00110

Department of computer science BCA


15
St.Antony’s college, peruvanthanam

II. Subtract Larger number from Smaller number

Step1: Determine the 1’s complement of second number

Step2: Add this1’s complement to the first number

Step3: There is no carry. The answer has an opposite sign and the result
must be in 1’s complement form

Example:

1001-1101=?

Step1: 1’s complement =0010

Step2: Add 1001 +

0010

1011

Step 3: 1’s complement of result and put opposite sign = - 0100

1001-1101= -0100

Applications of 2’s complement


We can use the 2’s complement method for the subtraction of binary
numbers. We can subtract binary numbers by using 2’s complement
through addition

I. Subtract smaller number from Larger number

Step1: Determine the 2’s complement of second number

Step2: Add this2’s complement to the first number

Step3: Discard the carry

Department of computer science BCA


16
St.Antony’s college, peruvanthanam

Example:

1100-1001=?

Step1: 2’s complement = 0110+1 =0111

Step2: Add 1100 +

0111

10011

Step3: Discard the carry. Take the result

0011

1100-1001=0011

II. Subtract Larger number from Smaller number

Step1: Determine the 2’s complement of second number

Step2: Add this2’s complement to the first number

Step3: There is no carry. The answer has an opposite sign and the result
must be in 2’s complement form

Example:

10111-11111=?

Step1: 2’s complement=00000+1=00001

Step2:Add 10111 +

00001

11000

Department of computer science BCA


17
St.Antony’s college, peruvanthanam

Step3: Take 2’s complement and put opposite sign

00111+1= - 01000

10111-11111= -01000

Sign-Magnitude form
This form is used to represent signed numbers in binary format.It is also
called sign & magnitude form.

We use leftmost bit of binary number to represent the sign and the
remaining bits are called magnitude. If the sign bit is 0, then the number is
positive. If the sign bit is 1, then the number is negative. We can represent
the number either in 8 bit format or in 16 bit format.

Example: Represent -23 in 8 bit format

23 =10111

23 in 8 bit format 00010111

-23 in 8 bit format 1 0010111

Sign bit Magnitude

BCD Numbers

BCD means binary coded decimal. In this System digit is represented by the
binary code of 4 bits. The BCD numbers contains only digits from 0-9.The
8421 code is an example of BCD code. Here we can represent the numbers
from 0-15.But the valid BCD numbers are from 0-9,Others are considered
as invalid number(10-15)

Department of computer science BCA


18
St.Antony’s college, peruvanthanam

To express any decimal number in BCD, replace each decimal digit by


binary code of 4 bits

Example: 1472

1 4 7 2

0001 0100 0111 0010

Answer= 0001 0100 0111 0010

BCD Addition

Step1: Add two numbers using the rules of binary addition

Step2: If the 4bit sum is equal/less than 9, it is a valid BCD number. So


resulting number is the final one

Step3: If the 4 bit sum is >9, then the result is the invalid BCD number. So that
add 6 (0110) to the result to make up the valid BCD number

Example: 1001 +0011

1001 +

0011

1100 invalid BCD number, so add 6(0110)

1100 +

0110

0001 0010

Answer= 0001 0010

Department of computer science BCA

You might also like