Decimal to Hex converter

 Enter decimal number: 10 Hex number: 16 Hex signed 8-bit: 16 Hex signed 16-bit: 16 Hex signed 32-bit: 16 Binary number: 2

Hex to decimal converter ►

How to convert from decimal to hex

For decimal number x:

1. Get the highest power of 16 that is less than the decimal number x:

16n < x, (n=1,2,3,...)

2. The high hex digit is equal to the integer if the decimal number x divided by the highest power of 16 that is smaller than x:

dn = int(x / 16n)

3. Calculate the difference Δ of the number x and the hex digit dn times the power of 16, 16n:

Δ = x - dn × 16n

4. Repeat step #1 with the difference result until the result is 0.

Example

Convert x=603 to hex:

n=2, 162=256 < 603

n=3, 163=4096 > 603

So

n = 2

d2 = int(603 / 162) = 2

Δ = 603 - 2×162 = 91

n = 1, x = Δ = 91

d1 = int(91 / 161) = 5

Δ = 91 - 5×161 = 11

n = 0, x = Δ = 11

d0 = int(11 / 160) = 1110 = B16

Δ = 11 - 11×160 = 0

(d2d1d0)  = 25B

So

x = 60310 = 25B16

Decimal to hex conversion table

Decimal

base 10

Hex

base 16

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
16 10
17 11
18 12
19 13
20 14
21 15
22 16
23 17
24 18
25 19
26 1A
27 1B
28 1C
29 1D
30 1E
40 28
50 32
60 3C
70 46
80 50
90 5A
100 64
200 C8
1000 3E8
2000 7D0

Hex to decimal converter ►