NUMBER SYSTEM (Binary , Decimal , Hexadecimal and their Inter conversions)

"A set of values used to represent different quantities is known as Number System". 

A number system defines how a number can be represented using distinct symbols. A number can be represented differently in different systems. 

There are Decimal , Binary , Octal and Hexadecimal number systems.

1. Decimal Number System:
- Use in our day-to-day life.

- Ten symbols or digits 0,1,2,3,4,5,6,7,8,9 are used to form decimal numbers.

- Base or Radix of a number system = Total numbers of digits available in the system to represent numbers.
Therefore Base or Radix of Decimal Number System = 10

- It is also called base–10 numbers system.

- The successive position towards left represent as units, tens, hundred, thousand etc.

- The weight of each digit of a  decimal number depends on its relative position within the number.

Example:
Decimal Number = 2586
=2*103 + 5*102 + 8*101 + 6*100
(Weight of the 1st digit)
= 2000 + 500 + 80 + 6 = 2586
Decimal Number = 15.52
=1*101 + 5*100 + 5*10-1+ 2*10-2
=10 + 5 + 0.5 + 0.02
=15.52

2. Binary Number System 
- Use in the Computer System

- It uses only 2 digits 0 & 1 to form binary Numbers.

- Base (or radix) of the binary number system = 2

- In short binary digit (0 or 1) is called a bit.

- The storing or computing electronic elements of a computer has only two stable states. 

The output of such element at any time is either High (5 Volts) or Low (0 volts). These stable states can be represented by 1 & 0 respectively.

High (5 volts)=1 & Low (0 Volts)= 0

Due to this very limitation, a computer can understand information composed of only 0s & 1s (i.e. in binary digits).

- Zero is represented by 0 & One is represent by 1. There is no digit available to represent two, three, four, etc. Therefore using position technique: Two is written as 10 Three is written as 11
Four is written as 100 

- The weight of each binary bit of a binary number depends on its relative position within the number. 

Example.
- Example: Binary Number = 1101.1
= 1 * 23 + 1 * 22 + 0 * 21 +1 * 20 +1*2-1
= 8+4+0+1+0.5 = 13.5 (Decimal No.)

3. Octal Number System:
- It is also used in Computer industry

- It uses eight digits 0, 1, 2, 3, 4, 5, 6, 7

- The Base or Radix = 8

- There are only 8 bits in the Octal Number System and 8 = 23, so an Octal Number is represented by a group of three binary bits.

0 000 46 100 110
1 001 146 001 100 110
4 100
6 110

The binary representation of an Octal Number is also called Binary Coded Octal Number.

Example:
Octal Number = (2057.4)8
=2*83+0*82 +5*81 +7*80 +4*8-1
=1024+0+40+7+0.5
= (1071.5)10

4. Hexadecimal Number System:
- It is now extensively used in computer industry.

- 16 Symbols or digits are used. The 1st 10 digits are the digits of a decimal system 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The remaining 6 digits are denoted by A, B, C, D, E & F, representing the decimal value 10, 11, 12, 13, 14, 15 respectively.

- The base (or radix) is 16.

16=24 therefore a hexadecimal digit is represented by a group of 4 binary bits.

5 0101 86 1000 0110
10 = A 1010 5E 0101 1110
13 = D 1101 3B7 0011 1011 0111
15 = F 1111

The binary representation of hexadecimal number is also called Binary Coded Hexadecimal Numbers.

Example:
Hexadecimal Number= 1AF.5
=1*162+A*161+F*160+5*16-1
= 1*256+10*16+15*1+5/16
= 256+160+15+0.3125
= (431.3125)10

CONVERSIONS

1. DECIMAL TO OTHER BASE
2. OTHER BASE TO DECIMAL
3. OCTAL TO OTHER BASE
4. HEXADECIMAL TO OTHER BASE
5. BINARY TO OCTAL AND HEXADECIMAL

1. DECIMAL TO OTHER BASE SYSTEM

Steps
Step 1 − Divide the decimal number to be converted by the value of the new base.

Step 2 − Get the remainder from Step 1 as the rightmost digit (least significant digit) of new base number.

Step 3 − Divide the quotient of the previous divide 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, getting remainders from right to left, until the quotient becomes zero in Step 3.
The last remainder thus obtained will be the Most Significant Digit (MSD) of the new base number.


Examples −


Decimal to Binary
Decimal Number: 2910 
Calculating Binary Equivalent −
                                    RESULT       REMAINDER
Step 1             29 / 2         14                       1
Step 2             14/2             7                        0
Step 3               7/2             3                        1   
Step 4                3/2           1                         1         
Step 5              1/2             0                         1

As mentioned in Steps 2 and 4, the remainders have to be arranged in the reverse order so that the first remainder becomes the Least Significant Digit (LSD) and the last remainder becomes the Most Significant Digit (MSD).
Decimal Number − 2910 = Binary Number − 111012.

Decimal to Octal 
( base 10 to base 8) 
Example: 
Convert (177)10 to octal 
177 / 8 = 22 remainder is 1 
22 / 8 = 2 remainder is 6 
2 / 8 = 0 remainder is 2  
Answer = 2 6 1 

Note: the answer is read from bottom to top as (261)8, the same as with the binary case. 

Conversion of decimal fraction to octal fraction is carried out in the same manner as decimal to binary except that now the multiplication is carried out by 8.

Decimal to Hexadecimal
  1. Divide the decimal number by 16. Treat the division as an integer division.
  2. Write down the remainder (in hexadecimal).
  3. Divide the result again by 16. Treat the division as an integer division.
  4. Repeat step 2 and 3 until result is 0.
  5. The hex value is the digit sequence of the remainders from the last to first.

Convert decimal 3000 to hexadecimal
Divisor Base 10 number Remainder in hex


3000/16 =187
187/16=11 remainder 8 = 8
11/16 =0 remainder 11 = B
0 /16 remainder 11 = B

Answer equals to BB8 hexadecimal. 


2. OTHER BASE TO DECIMAL SYSTEM

Steps

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 the products calculated in Step 2. The total is the equivalent value in decimal.


Examples


Binary to Decimal
Binary Number − 111012
Calculating Decimal Equivalent −
StepBinary NumberDecimal Number
Step 1111012((1 × 24) + (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20))10
Step 2111012(16 + 8 + 4 + 0 + 1)10
Step 31110122910
Binary Number − 111012 = Decimal Number − 2910

Octal to Decimal 
( base 8 to base 10) 
Example: 
convert (632)8 to decimal 
= (6 x 82) + (3 x 81) + (2 x 80) = (6 x 64) + (3 x 8) + (2 x 1) = 384 + 24 + 2 = (410)10 

Hexadecimal to Decimal

Convert the number 35432 HEXADECIMAL to DECIMAL

2x(16^0) + 3x(16^1) + 4x(16^2) + 5x(16^3) + 3x(16^4) 
=2 + 3x16 + 4*256 + 5*4096 + 3*65536 
=2 + 48 + 1024 + 20480 + 196608 
=218162

 3. OCTAL TO OTHER BASE

Octal is first converted to decimal , then decimal is converted to binary or hexadecimal.


Consider the given octal number
Let the given number have n number of digits

Step 1: Multiply each digit of the number with 8n-1, when the digit is in the nth position from the right end of the number.If the number has decimal part the multiply each digit in the decimal part by  when the digit is in the mth position from the decimal point.

Step 2: Add all terms after multiplication.

Step 3: The obtained value is the equivalent decimal number.


PROCEED FURTHER FOR CONVERTING THE OBTAINED DECIMAL TO BINARY OR HEXA-DECIMAL.

Step 4: Consider the obtained decimal number, divide it by 2 in case of binary and by 16 in case of hexadecimal.

Step 5: Note the remainder.

Step 6: Continue the above two steps for the quotient till the quotient is zero.

Step 7: Write the remainders in the reverse order.

Step 8: The obtained number is the equivalent binary/ hexadecimal number for the given octal number.


EXAMPLE

Octal to Decimal

1238 = 1*82 + 2*81 + 3*80 = 64 + 16 + 3 = 73 So the decimal equivalent of the number 1238 is 7310.

Octal To Binary

Convert 418 to a binary number.
Solution:

Given number is 418

418 = (4 * 81) + (1 * 80)

= 4 * 8 + 1 * 1

= 32+1

= 33(Decimal number)

Now convert this decimal number to a binary number.

2 | 33
2 | 16 -- 1
2 | 8  -- 0
2 | 4  --0
2 | 2  -- 0
      1 -- 0

The binary number is 1000012



Octal To Hexadecimal

Convert 10028 to hexadecimal
Solution:

 
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




  4. HEXADECIMAL TO OTHER BASE


Step 1: Consider the given hexadecimal number.

Step 2: First count the number of digits in the number

Step 3: If n is the position of the digit from the right end then multiply each digit with 16n-1

Step 4: Add the terms after multiplication.

Step 5: Resultant is the equivalent decimal form.

PROCEED FOR CONVERTING THIS DECIMAL NUMBER TO BINARY / OCTAL NUMBER.

Step 6: Divide the decimal number with 2 in case of binary and 8 in case of octal.

Step 7: Note down the remainder.

Step 8:Continue step 6 and 7 with the quotient, until the quotient is zero.

Step 9: Write the remainders in reverse order.

Step 10: The obtained number is the required result.


EXAMPLE

1.
Convert the Hex number 2AF3 into its equivalent Decimal Number.
The sum of all the units yield the equivalent decimal value
(2 x 163) + (10 x 162) + (15 x 161) + (3 x 160) = 10995




2. Find the equivalent octal form of C116

Solution:
 
Given hexadecimal number is C1

C116 = (C * 161) + (1 * 160)

= C * 16 + 1 * 1

=12 * 16 + 1

= 192 + 1

=193 (Decimal form)

Now we have to convert this decimal to octal

8 | 193
| 24 -- 1
| 3 -- 0
| 0 --3

The octal number is 3018

C116 = 3018


3. Convert A2B16 to a equivalent binary number 
Solution:

Given hexadecimal number is A2B

A2B16 = (A * 162) + (2 * 161) + (B * 160)
= (A * 256) + (2 * 16) + (B * 1)

= (10 *256) + 32 + 11

= 2560 + 43

= 2603(Decimal number)

Now we have to convert 2603 to binary

2 | 2603
2 |1301 -- 1
2 | 650 -- 1
2 | 325 -- 0
2 | 162 -- 1
| 81  -- 0
2 | 40 -- 1
2 | 20 -- 0
| 10 -- 0
| 5 -- 0
2 | 2 -- 1
2 | 1 -- 0
| 0 -- 1

The binary number is 1010001010112

A2B16 = 1010001010112


BINARY TO OCTAL


Step 1:Take the given binary number.

Step 2:Multiply each digit by 2n-1 where n is the position of the digit from the decimal.If it is a decimal number multiply the each digit in the decimal part by ,m is the position of the digit from the decimal point.

Step 3:The resultant is the equivalent decimal number for the given binary number.

Step 4: Divide the decimal with 8

Step 5: Note the remainder

Step 6: Continue the above two steps with the quotient till the quotient is zero

Step 7: Write the remainder in the reverse order

Step 8: The resultant is the required octal number for the given binary number.

EXAMPLES


 1. Convert 011012 to octal
Solution:

Given binary number is 011012
First we convert given binary to decimal
01101= (0 * 24) + (1 * 23) + (1 * 23) + (0 * 2) + (1 *20)
= 0 + 8 + 4 + 0 +1
= 13(Decimal form)
Now we will convert this decimal to octal form
8 | 13
-------
8 | 1 -- 5
-------
8 | 0 -- 1



Correct answer is equivalent octal form is 158

2. Convert 0011001102 to octal
Solution:

Given binary number is 0011001102
First we convert given binary to decimal
001100110= (0 * 28) + (0 * 27) + (1 * 26) + (1 * 25 ) + (0 * 24) + (0 * 23) + (1 * 22) + (1 * 21) + (0 * 20)
= 0 + 0 + 64 + 32 + 0 + 0 + 4 + 2 + 0
= 64 + 38
= 102(Decimal form)
Now we will convert  decimal to octal form
8 | 102

-------
8 | 12 -- 6
-------
8 | 1 -- 4
-------

8 | 0 --1


Correct answer is equivalent octal form is 1468