gettoolz.app

Decimal to hex converter

Convert decimal numbers to hex — by repeated division by 16, every step shown. Exact at any size, with a worked example and a table of common values. Free, and computed in your browser.

Part of developer tools.

Base

Binary

10101101

Octal

255

Decimal

173

Hexadecimal

AD

Decimal to hex table

DecimalHex
00
11
22
33
44
55
66
77
88
99
10A
11B
12C
13D
14E
15F
1610
10064
1277F
255FF
256100
10003E8
1024400
40961000
65535FFFF
4294967295FFFFFFFF
18446744073709551615FFFFFFFFFFFFFFFF

The last rows are the largest 32-bit and 64-bit unsigned values. The second is past the point where ordinary JavaScript numbers start rounding; the table and the converter above both compute with BigInt, so every digit is exact.

How to convert decimal to hex

Divide the decimal number by 16, write down the remainder, and repeat with the quotient until it reaches 0. The remainders, read from the last one back to the first, are the hex digits. For 173: 173 ÷ 16 = 10 remainder 13 (D); 10 ÷ 16 = 0 remainder 10 (A). Read upwards, that is AD. Remainders from 10 to 15 are written as the letters A to F — that is the only extra step compared with any other base.

Decimal and hex side by side

The largest 16-bit value is 65535 in decimal and FFFF in hex: 5 digits against 4. A decimal digit is worth log₂ 10 ≈ 3.32 bits, against 4 for a hex digit — not a whole ratio, so decimal and hex digits never line up and there is no digit-by-digit shortcut: the whole number has to be divided down, as above. Hex is the usual way to write bytes — colours like #FF8800, memory addresses, hashes, escape sequences — because a byte is always exactly two hex digits. In JavaScript and Python source, 173 is written 173 with no prefix in decimal and 0xAD in hex. Paste a prefixed number into the converter and it switches to the matching base; a number with no prefix is read in the selected base — decimal on this page.

Other conversions

Going the other way? Hex to decimal converter.

Or open the full number base converter and see a number in all four bases at once.