🔢

Hex Calculator

Perform hexadecimal arithmetic and convert between hex, decimal, binary, and octal.

Results

Hexadecimal Number System

Hexadecimal (base 16) is a numeral system that uses 16 distinct symbols: 0–9 and A–F. It is the most common shorthand for binary data in computing because each hex digit maps exactly to 4 binary bits, making two hex digits represent one byte (0x00–0xFF = 0–255).

Hex Digits A–F

Since base 16 needs 16 symbols but we only have 10 decimal digits, the letters A through F extend the set: A=10, B=11, C=12, D=13, E=14, F=15. The maximum two-digit hex value is FF = 15×16 + 15 = 255.

Converting Hex to Decimal

Multiply each digit by 16 raised to its position (from right, starting at 0): 2AF = 2×16² + A×16¹ + F×16⁰ = 2×256 + 10×16 + 15×1 = 512 + 160 + 15 = 687.

Applications in Computing

Memory addresses (0x7fff5fbff3e0), RGB color codes (#1A2B3C), UUID/GUID identifiers, IPv6 addresses (2001:0db8:85a3::8a2e:0370:7334), machine code listings, and hash values (SHA-256 outputs) are all commonly expressed in hex. Programmers prefix hex with 0x (C), # (CSS), or $ (assembly).

Hex Color Codes

CSS colors in hex: #RRGGBB where each pair is a hex number 00–FF. #FF0000 = red (R=255, G=0, B=0). #00FF00 = green. #0000FF = blue. #FFFFFF = white. #000000 = black. Short form #RGB expands each digit: #F80 = #FF8800 (orange).

Hex to Decimal Conversion Example

Convert 3F7 (hex) to decimal. Write out the positional values from right: position 0 is 16⁰=1, position 1 is 16¹=16, position 2 is 16²=256.

3F7 = (3 × 256) + (F × 16) + (7 × 1) = 768 + (15 × 16) + 7 = 768 + 240 + 7 = 1015.

Hex Digit to Binary Reference

HexDecimalBinaryHexDecimalBinary
000000881000
110001991001
440100A101010
770111F151111

Frequently Asked Questions

0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. Where A=10, B=11, C=12, D=13, E=14, F=15. The max single-digit value is F=15.

FF = F×16 + F = 15×16 + 15 = 240 + 15 = 255. This is the maximum value of a single byte. 0x100 = 256.

Add column by column. If sum > 15, write (sum mod 16) and carry 1. Example: F + 1 = 16 decimal, which is 10 in hex (write 0, carry 1). FF + 1 = 100 in hex = 256 in decimal.

Replace each hex digit with its 4-bit binary equivalent. F→1111, A→1010, 5→0101. So FA5 → 1111 1010 0101 in binary.

The "0x" prefix is a C-language convention indicating the following digits are hexadecimal. Other notations: #FF (CSS), &HFF (Visual Basic), $FF (assembly), FFh (older notation).

Repeatedly divide by 16 and note remainders. Example: 255 ÷ 16 = 15 remainder 15 (F). 15 ÷ 16 = 0 remainder 15 (F). Read remainders from bottom to top: FF. So decimal 255 = hex FF.

Modern computers use 64-bit or 32-bit addresses. A 32-bit address takes 10 decimal digits or 8 hex digits. Hex is more compact and maps directly to groups of 4 binary bits, making it easier for developers to read and write memory dumps and register values.

Formula sources & accuracy standards: Calculator Methodology · Editorial Policy