The HexaDecimal numeral system is a type of number system in Mathematics and computing that represents a number using a base of 16. This means it has 16 symbols to represent a number.

The symbols are: **1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F**

Hexadecimal numbers are widely used in Software development and system designing because they provide a human-friendly representation of binary-coded values.

A number 35 can be a Hexadecimal or a Decimal provided what is its base. If the base is 16 i.e, (35)_{16}, it is a Hex number, and if it is (35)_{10}, then a Dec number

**Hexadecimal Table**

Decimal Numbers | Hexadecimal Numbers |

0 | 0 |

1 | 1 |

2 | 2 |

3 | 3 |

4 | 4 |

5 | 5 |

6 | 6 |

7 | 7 |

8 | 8 |

9 | 9 |

10 | A |

11 | B |

12 | C |

13 | D |

14 | E |

15 | F |

**Hexadecimal to Decimal Conversion**

As we have seen above the Hex system uses base 16, this base is used to convert a Hex number to a Dec number. Each digit of a Hex is multiplied with a power of 16. The power starts at 0 from the right moving forward towards the right with the increase in power. For the conversion to complete, the multiplied numbers are added.

Deimal Number = d_{n-1} × 16^{r-1}+….+ d_{2} × 16^{2} + d_{1} × 16^{1} + d_{0} × 16^{0}.

Where

- n = number of digits.
- r = placement of the digit.

**Example: **Let’s Convert a hexadecimal number (35)_{16} to its decimal form.

(35)_{16} = 3 × 16^{1} + 5 × 16^{0}

= 3 × 16 + 5 × 1

= 48 + 5

= 53

Therefore, (35)_{16} = (53)_{10}

**Example:** Let’s convert another Hexadecimal number (3C)_{16} to Decimal form.

(3C)_{16} = (3 × 16^{1}) + (12 × 16^{0}) = (60)^{10}

**Decimal to Hexadecimal Conversion**

There are various methods you can convert a decimal number to a hexadecimal number, but the easy one is the division method. First, divide the decimal number by 16, considering the number as an integer, and keep aside the remainder. Again divide the quotient by 16 and repeat till you get the quotient value equal to zero.

Now take the values of the remainder’s left in the reverse order to get the hexadecimal numbers.

**Example:** Let’s convert the decimal number 30 to hexadecimal

If you see the table above, you will get the point that 1 in Dec corresponds to 1 in Hex and 14 in Dec corresponds to E in Hex.

**Converting a Decimal to Hexadecimal in Python Code**

Python is a very easy language because of the presence of lots of libraries to ease your task. It has the ‘hex’ class for this purpose. See the code below:

```
decimal = 30
hexadecimal = hex(dcimal)
print(hexadecimal)
```

**Output:**1E

**We can also do it using Loop**

```
table = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A' , 'B', 'C', 'D', 'E', 'F']
dec = 30
hex = ''
while(dec>0):
remainder = dec%16
hex = table[remainder]+ hex
dec = dec//16
print("Hexadecimal: ", hex)
```

**Output:**Hexadecimal: 1E

**Converting a Hexadecimal to Decimal in Python Code**

Similarly, we can convert Hex to Dec in Python easily, see the code below:

```
hex = "1E"
dec = int(hex, 16)
print(dec)
```

**Output:**30