Hexadecimal Number Calculator

Enter the arithmetic operation and the hexadecimal numbers you want to calculate. The entered values should be positive integers. Decimal results are displayed truncated to the unit.

Invalid hexadecimal 1
Invalid hexadecimal 2

In hexadecimal:

=

In decimal:

=

Share this calculator

What Are Hexadecimal Numbers? With Examples

Hexadecimal numbers are a numerical representation that uses 16 digits instead of the 10 digits used in the decimal system. The digits used are the numbers 0 to 9 and the letters A, B, C, D, E, and F. Hexadecimal numbers are often used in programming to represent values in the binary numbering system.

Some examples of hexadecimal numbers include:

  • 1F (31 in decimal)
  • A0 (160 in decimal)
  • FF (255 in decimal)

How to Add Hexadecimal Numbers?

Adding hexadecimal numbers is similar to adding decimal numbers, but with some important differences due to the different number base. Here's an example of how to add two hexadecimal numbers:

Example: Adding 5A (90 in decimal) and 3F (63 in decimal) step by step

  1. We start by adding the units digits (or least significant digits) first: A + F = 17 (in decimal)
  2. As the result is greater than 15, we carry 1 to the next column
  3. We continue adding the other columns: 5 + 3 + 1 (carried) = 9
  4. The final result is 99 (153 in decimal)

How to Subtract Hexadecimal Numbers?

Subtracting hexadecimal numbers is similar to subtracting decimal numbers, but with some important differences due to the different number base. Here's an example of how to subtract two hexadecimal numbers:

Example: Subtract 7B (123 in decimal) - 5F (95 in decimal) step by step

  1. We start by subtracting the units digits (or least significant digits) first: B - F. Since B (11 in decimal) is less than F (15 in decimal), we must "borrow" one from the tens place of the hexadecimal number. In this case, we would have 1B (27 in decimal) - F (15 in decimal) = C (12 in decimal).
  2. We continue subtracting the other columns: (7 - 1) - 5 = 1, as in the previous step, we borrowed one from 7.
  3. The final result is 1C (28 in decimal)

How to Convert Hexadecimal to Decimal

To convert a hexadecimal number to decimal, the following formula is used:

(digit_1 · 16^(n-1)) + (digit_2 · 16^(n-2)) + ... + (digit_n · 16^0)

Where digit_1 is the leftmost digit of the hexadecimal number, digit_2 is the next, and so on, and n is the total number of digits that make up the hexadecimal number to be converted.

Example: Convert the hexadecimal number 5A to decimal.

  1. Determine the value of n. In this case, n = 2
  2. Transform each hexadecimal digit into its decimal form. In this case, 5 = 5 and A = 10
  3. Replace the digits in their decimal form in the formula. This way we have:
(5 · 16^1) + (10 · 16^0) = (5 · 16) + (10 · 1) = (80) + (10) = 90

Differences Between Decimal and Hexadecimal Systems

Decimal System

It is a base-10 numbering system and is the worldwide standard. Each digit that makes up a decimal number must take values between 0 and 9. If the digit value exceeds 9, a new digit must be added for its correct representation.

Hexadecimal System

It is a base-16 numbering system and is commonly used in the world of digital graphics to represent colors on a monitor. Each digit that makes up a number can take values between [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F]. If the digit value exceeds F, a new digit must be added for its correct representation.

Table of Equivalents Between Decimal, Hexadecimal, and Binary Numbers

Representation of numbers in each of the numbering systems.

Decimal System
Hexadecimal System
Binary System
0
0
0
1
1
1
2
2
10
3
3
11
4
4
100
5
5
101
6
6
110
7
7
111
8
8
1000
9
9
1001
10
A
1010
11
B
1011
12
C
1100
13
D
1101
14
E
1110
15
F
1111