Hex Calculator

Perform hexadecimal arithmetic (add, subtract, multiply, divide, AND, OR, XOR), convert between hex, decimal, binary, octal and RGB, and pick hex colors with HSL values. Free online hex calculator.

Hex Calculator

Perform hex arithmetic, convert between number systems, and pick hex colors

= 6719 dec
= 4080 dec
1A3F+0FF0=2A2F
Hexadecimal
2A2F
Decimal
10799
Binary
10101000101111
Octal
25057

Free Hex Calculator Online - Hexadecimal Arithmetic, Converter & Color Picker

Perform hexadecimal calculations, convert between number systems, and pick hex colors with our free all-in-one hex calculator. Supports arithmetic operations, bitwise logic, and real-time conversions.

What is Hexadecimal?

Hexadecimal (often shortened to "hex") is a base-16 number system that uses sixteen distinct symbols to represent values. It uses the digits 0 through 9 for values zero to nine, and the letters A through F (or lowercase a through f) for values ten to fifteen. Hexadecimal is the most widely used number system in computing and digital electronics because it provides a human-friendly way to represent binary-coded values.

The word "hexadecimal" combines the Greek word "hex" (meaning six) with the Latin word "decem" (meaning ten). Each hexadecimal digit represents exactly four binary digits (bits), making hex an efficient shorthand for representing binary data. For example, the binary number 11111010 can be written as simply FA in hexadecimal.

Understanding the Hex Number System

The hexadecimal system is a positional numeral system with a radix (base) of 16. Unlike our everyday decimal system (base 10) which uses ten symbols, hex uses sixteen symbols:

Hex DigitDecimal ValueBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

In positional notation, each position in a hex number represents a power of 16. The rightmost digit is the 16^0 (ones) position, the next is 16^1 (sixteens), then 16^2 (256s), 16^3 (4096s), and so on. For example, the hex number 2F3 equals: (2 × 256) + (15 × 16) + (3 × 1) = 512 + 240 + 3 = 755 in decimal.

Hex to Decimal Conversion

Converting hexadecimal to decimal involves multiplying each digit by its corresponding power of 16 and summing the results. Here is the step-by-step process:

  1. Write down the hex number and identify each digit's position from right to left (starting at position 0)
  2. Convert each hex digit to its decimal equivalent (A=10, B=11, C=12, D=13, E=14, F=15)
  3. Multiply each digit by 16 raised to the power of its position
  4. Add all the results together

Example: Convert hex 1A3F to decimal:

  • F (position 0): 15 × 16^0 = 15 × 1 = 15
  • 3 (position 1): 3 × 16^1 = 3 × 16 = 48
  • A (position 2): 10 × 16^2 = 10 × 256 = 2560
  • 1 (position 3): 1 × 16^3 = 1 × 4096 = 4096
  • Total: 15 + 48 + 2560 + 4096 = 6719

Hex Arithmetic Operations

Hexadecimal arithmetic follows the same rules as decimal arithmetic, but carries occur at 16 instead of 10. Our hex calculator supports the following operations:

Addition

When adding two hex numbers, add digit by digit from right to left. If the sum of any column is 16 or greater, carry 1 to the next column. For example, 0x8 + 0x9 = 0x11 (17 in decimal).

Subtraction

Hex subtraction works similarly to decimal subtraction. When a digit in the minuend is smaller than the corresponding digit in the subtrahend, borrow 1 (which equals 16 in decimal) from the next higher position.

Multiplication

Hex multiplication can be performed by converting to decimal, multiplying, and converting back. Alternatively, you can multiply directly in hex using the same long multiplication method, keeping in mind that each position represents powers of 16.

Division

Hex division divides one hex number by another, returning the integer quotient. Division by zero is undefined.

Bitwise Operations (AND, OR, XOR)

These operations work on the binary representation of the hex values:

  • AND: Each bit is 1 only if both corresponding bits are 1
  • OR: Each bit is 1 if at least one corresponding bit is 1
  • XOR: Each bit is 1 if the corresponding bits are different

Hex in Computing

Hexadecimal is deeply embedded in computing and appears in many contexts:

Memory Addresses

Computer memory addresses are typically expressed in hexadecimal. A 32-bit address like 0x7FFF5FBFF appears much more readable in hex than in binary (0111111111111111010111111011111111111) or decimal (140,734,799,359). Debuggers, disassemblers, and low-level programming tools always display memory addresses in hex.

Color Codes

In web development and digital design, colors are commonly represented as hex codes in the format #RRGGBB, where RR, GG, and BB are two-digit hexadecimal numbers specifying the intensity of red, green, and blue channels (0x00 to 0xFF, or 0 to 255 in decimal). For example, #FF8800 represents orange (255 red, 136 green, 0 blue). CSS also supports #RGB shorthand notation and #RRGGBBAA for colors with transparency.

MAC Addresses

Network interface controllers (NICs) are identified by MAC addresses, which are six pairs of hexadecimal digits separated by colons or hyphens (e.g., 00:1A:2B:3C:4D:5E). Each pair represents one byte of the 48-bit address.

Assembly Language and Machine Code

In assembly language programming and reverse engineering, machine code instructions and data are displayed in hexadecimal. For example, the x86 machine code for the NOP (no operation) instruction is 0x90. Hex editors allow programmers to view and edit the raw bytes of any file.

Unicode Characters

Unicode code points are commonly written in hexadecimal using the notation U+ followed by the hex value. For example, the emoji 😀 has the code point U+1F600. HTML entities can also use hex notation: 😀 renders the same emoji.

File Formats and Magic Numbers

Many file formats begin with specific hex sequences (magic numbers) that identify the file type. For example, PNG files start with 89 50 4E 47, PDF files with 25 50 44 46, and ZIP archives with 50 4B 03 04.

Hex Conversion Reference Table

Here is a comprehensive reference table for quick hex conversions:

DecimalHexBinaryOctal
0000000
1100011
2200102
3300113
4401004
5501015
6601106
7701117
88100010
99100111
10A101012
11B101113
12C110014
13D110115
14E111016
15F111117
16101000020
322010000040
64401000000100
1288010000000200
255FF11111111377
256100100000000400

Features of Our Hex Calculator

Our hex calculator provides three powerful tools in one:

Hex Arithmetic Tab:

  • Add, subtract, multiply, and divide hexadecimal numbers
  • Perform bitwise AND, OR, and XOR operations
  • Instant results displayed in hexadecimal, decimal, binary, and octal
  • Quick-load example calculations for common operations
  • Supports large numbers using BigInt for arbitrary precision

Hex Converter Tab:

  • Convert between hex, decimal, binary, octal, and RGB formats
  • Real-time conversion as you type
  • Automatic color preview when the value fits in RGB range
  • One-click copy for any converted value
  • Input validation for each number format

Hex Color Picker Tab:

  • Enter any hex color code (#RRGGBB)
  • Visual color preview with gradient overlay
  • Displays RGB values with visual channel bars
  • Displays HSL (Hue, Saturation, Lightness) values
  • Preset color palette for quick selection
  • Native color picker integration
  • Copy color values in multiple formats (HEX, RGB, HSL)

Frequently Asked Questions

What is the hexadecimal number system used for?

Hexadecimal is primarily used in computing to represent binary data in a more compact and readable format. It is used for memory addresses, color codes, MAC addresses, assembly language, debugging, network protocols, and file format specifications. Every two hex digits represent exactly one byte (8 bits), making hex ideal for working with byte-level data.

How do I convert hex to decimal manually?

To convert hex to decimal, multiply each hex digit by 16 raised to the power of its position (starting from 0 on the right) and sum the results. For hex A3: (10 × 16^1) + (3 × 16^0) = 160 + 3 = 163. Letters A-F represent values 10-15.

How do I convert decimal to hex manually?

To convert decimal to hex, repeatedly divide the number by 16 and record the remainders. Read the remainders in reverse order. For decimal 255: 255 ÷ 16 = 15 remainder 15 (F), 15 ÷ 16 = 0 remainder 15 (F). Reading backwards: FF.

What is the difference between hex and binary?

Binary is base-2 (uses 0 and 1) while hexadecimal is base-16 (uses 0-9 and A-F). Each hex digit represents exactly 4 binary digits. Hex is more compact: 8 binary digits (a byte) can be written as just 2 hex digits. For example, binary 11111111 equals hex FF.

Why does hex use letters A through F?

The hexadecimal system needs 16 unique symbols to represent values 0 through 15. The digits 0-9 cover values zero through nine, so the letters A-F were chosen to represent values ten through fifteen. This convention is universal across programming languages and computing standards.

What is a hex color code?

A hex color code is a 6-digit hexadecimal number (often prefixed with #) that represents a color in the RGB color model. The format is #RRGGBB where RR is the red component, GG is green, and BB is blue, each ranging from 00 (0) to FF (255). For example, #FF0000 is pure red.

Can hex numbers be negative?

Yes, hexadecimal can represent negative numbers. In computing, negative numbers are typically represented using two's complement notation. In our calculator, the arithmetic operations can produce negative results which are displayed with a minus sign prefix.

What is the largest number I can represent in hex?

There is no theoretical limit to the size of a hex number — you can keep adding digits. However, in practice, the number of digits is limited by the data type or storage available. A 32-bit value can represent hex numbers up to FFFFFFFF (4,294,967,295 in decimal), and a 64-bit value up to FFFFFFFFFFFFFFFF. Our calculator uses arbitrary precision (BigInt) to handle very large hex numbers.

How do I type hexadecimal on a keyboard?

Hex digits 0-9 are typed normally. For hex digits A-F, simply type the corresponding letter keys. In many programming languages, hex literals are prefixed with 0x (e.g., 0xFF) or 0X. In HTML and CSS, hex color codes are prefixed with # (e.g., #3B82F6).

What is the relationship between hex and octal?

Hexadecimal is base-16 and octal is base-8. Each hex digit equals 4 binary bits, while each octal digit equals 3 binary bits. To convert between them, first convert to binary, then regroup the bits. Three hex digits (12 bits) equal four octal digits (12 bits).

Why is hex preferred over decimal in programming?

Hex is preferred because it aligns naturally with binary representation. Each hex digit maps to exactly 4 bits, making it easy to visualize and manipulate individual bits and bytes. Decimal does not have this property — a decimal digit does not correspond to a fixed number of bits. This makes hex invaluable for bitwise operations, memory manipulation, and low-level programming.

Why Use Our Hex Calculator?

  • Completely free with no registration required
  • Three powerful tools in one — arithmetic, converter, and color picker
  • Real-time results that update as you type
  • Multiple output formats — see values in hex, decimal, binary, and octal simultaneously
  • Bitwise operations — AND, OR, XOR for logic calculations
  • Color support — preview and analyze hex color codes with RGB and HSL breakdowns
  • Mobile responsive — works perfectly on phones, tablets, and desktops
  • Privacy first — all calculations happen in your browser, no data is sent to any server