AJ Designer

Hex Calculator

Set values for a common case:

Hexadecimal =

FF

Conversion Details

Decimal
255
Binary
11111111
Byte width
1 byte
Share:

Decimal to Hexadecimal

Convert a base-10 integer into base 16. Divide the decimal by 16 repeatedly; each remainder is a hex digit, read from the last division to the first. Digits 10–15 are written as A–F.

decimal → base 16

Hexadecimal to Decimal

Convert a hex value into base 10. Multiply each digit by 16 raised to the power of its position (counting from 0 on the right) and sum the results. Inputs are case-insensitive.

base 16 → decimal

Hex Addition

Add two hex numbers. Sum digit-by-digit from the right, carrying when a column total reaches 16. Useful for offsetting memory addresses or summing byte counts.

a + b (base 16)

Hex Subtraction

Subtract one hex number from another. Borrow 16 from the next column when needed. Returning a negative is allowed in this calculator (no two's complement).

a − b (base 16)

Hex Multiplication

Multiply two hex values using BigInt arithmetic so results stay exact even for 64-bit or 256-bit inputs. Common in cryptography and bit-packing routines.

a × b (base 16)

Hex Division

Integer division of two hex values, returning a hex quotient plus a hex remainder. Dividing by zero is rejected. Useful for splitting an address range into equal chunks.

a ÷ b (base 16)

How It Works

Hexadecimal is base 16. Each digit represents one of sixteen values: 0–9 keep their decimal meaning, and A–F stand for 10–15. Because 16 is 2 raised to the 4th, every hex digit maps to exactly four binary bits — a unit programmers call a nibble. That clean alignment is why hex is the preferred shorthand for binary in colors, memory dumps, MAC addresses, and file signatures: two hex digits compactly describe one byte (8 bits), four describe one 16-bit word, and eight describe a 32-bit register. To convert a decimal value to hex, divide by 16 repeatedly and read the remainders from bottom to top; to convert hex to decimal, multiply each digit by its place value (16 raised to the position) and sum the results.

Example Problem

Convert 255 from decimal to hexadecimal:

  1. Divide 255 by 16. The quotient is 15 and the remainder is 15.
  2. Translate the remainder 15 to its hex digit: F. This becomes the rightmost (ones-place) digit.
  3. Divide the previous quotient, 15, by 16. The new quotient is 0 and the remainder is 15.
  4. Translate that remainder to F. This becomes the next (sixteens-place) digit.
  5. Because the quotient is now 0, the conversion is finished. Read the remainders from bottom to top: F, F.
  6. Therefore 255 decimal equals FF hexadecimal, which is also 11111111 in binary — exactly one full byte.

Result: 255 (decimal) = FF (hex) = 11111111 (binary) = 1 byte.

Key Concepts

Hex is most useful as a compressed view of binary. One hex digit always represents four binary bits (a nibble), so two hex digits always represent one byte. That is why hex shows up in three common places: web colors (#RRGGBB packs three bytes — red, green, blue — into six hex digits, so #FF0000 is red, #00FF00 is green, #0000FF is blue), memory addresses (a 32-bit pointer fits in 8 hex digits, a 64-bit pointer in 16), and ASCII / file headers (every byte in a hex dump is two characters, columns of 16 bytes line up neatly). Hex also reads as a number, so arithmetic still works — addresses can be added and subtracted, byte counts can be summed, and offsets can be multiplied without leaving base 16.

Applications

  • Web design — CSS color codes use #RRGGBB, where each pair is one byte of red, green, or blue (00 = none, FF = full)
  • Networking — MAC addresses are six hex bytes separated by colons, like 00:1A:2B:3C:4D:5E, and IPv6 addresses are eight 16-bit hex groups
  • Reverse engineering — disassemblers and hex editors display every byte as two hex digits so a 32-bit instruction is exactly eight characters
  • Memory addresses — pointers and offsets are written in hex because each digit maps to four bits, making bit-level math easy to read
  • File signatures (magic numbers) — PNGs start with 89 50 4E 47, ZIPs start with 50 4B 03 04, PDFs start with 25 50 44 46 — all read directly from a hex dump
  • Cryptography — hash digests (SHA-256, MD5), keys, and signatures are commonly represented as hex strings because they are compact and copy-paste safe

Common Mistakes

  • Confusing the letter O with the digit 0 — hex only uses 0–9 and A–F, never the letter O. If a digit looks like O, it is the number zero.
  • Forgetting that hex is case-insensitive — 0xff, 0xFF, and 0xFf all represent 255. This calculator displays results in uppercase for consistency, but accepts either case as input.
  • Reading hex as if it were decimal — the value 10 in hex is sixteen, not ten. Always remember that each position multiplies by 16, not 10.
  • Mistaking the 0x prefix for part of the value — the 0x is a notation that says ‘this number is hex,’ similar to how 0b precedes binary. The actual value starts after the x.
  • Treating leading zeros as significant — 00FF and FF are the same number, but leading zeros are often kept for alignment in byte tables and addresses.

Frequently Asked Questions

How do you convert hex to decimal?

Number each hex digit from right to left starting at position 0. Multiply each digit's value (0–9 stays as-is; A=10, B=11, C=12, D=13, E=14, F=15) by 16 raised to its position, then add the products. For example, FF = 15 × 16 + 15 × 1 = 240 + 15 = 255.

How do you convert decimal to hex?

Divide the decimal value by 16 and record the remainder. Replace the original value with the quotient and repeat until the quotient is 0. Read the remainders from last to first — that string of hex digits is your answer. For example, 255 ÷ 16 = 15 R 15, then 15 ÷ 16 = 0 R 15, so the answer is FF.

What is hexadecimal?

Hexadecimal is a number system with base 16. It uses sixteen distinct digits — 0 through 9 for the first ten values and A through F for ten through fifteen. Because 16 is a power of 2, each hex digit corresponds to exactly four binary bits, which makes hex a compact and human-readable way to write binary data.

Why do programmers use hex?

Hex compresses binary by a factor of four. A 32-bit integer takes 32 binary digits but only 8 hex digits, so memory addresses, machine code, and bit masks become much easier to read and type. Hex also aligns naturally to bytes — every two hex characters is exactly one byte — which matches how computers actually store information.

What does 0xFF mean?

The 0x is a prefix used in C, JavaScript, Python, and most programming languages to mark a literal as hexadecimal. So 0xFF means the hex value FF, which equals 255 in decimal and 11111111 in binary — the largest value that fits in a single 8-bit byte.

What is a nibble?

A nibble is exactly half of a byte — four bits. It is the smallest unit hex represents directly, because one hex digit always equals one nibble. Two nibbles together form one byte, which is why two hex digits is always one byte.

Why is hex case-insensitive?

The hex digits A through F are just names for the values 10 through 15; uppercase and lowercase carry no extra meaning. Most style guides recommend uppercase for human-readable output (this calculator follows that convention) but both forms parse to identical values.

What is the largest 1-byte hex value?

FF, which equals 255 in decimal and 11111111 in binary. Adding 1 to FF produces 100 in hex (256 in decimal), which requires a second byte. That overflow point is why unsigned 8-bit numbers in programming languages cap at 255.

Reference: Patterson & Hennessy, Computer Organization and Design: The Hardware/Software Interface (Morgan Kaufmann) — Appendix on number representation and base conversion.

How Hexadecimal Works

Each hex digit sits in a place worth a power of 16, so a hex string dn…d1d0 evaluates to the sum:

value = dn·16n + … + d1·161 + d0·160

Where:

  • di — the digit at position i, a value 0–15 written as 0–9 or A–F
  • 16i — the place value, growing by a factor of sixteen for each step left

The reverse direction — decimal to hex — repeatedly divides the decimal value by 16 and reads the remainders from last to first. One hex digit is one nibble (4 bits), and two hex digits are one byte (8 bits), which is why hex is the natural shorthand for binary.

Worked Examples

Bytes

Why is the largest single byte FF?

One byte is 8 bits, and 8 bits hold values from 0 to 255. Because every two hex digits represent one byte, the largest one-byte value is FF — two F's, each representing four 1-bits.

  • FF = 15 × 16 + 15 × 1.
  • 15 × 16 = 240. 15 × 1 = 15.
  • 240 + 15 = 255.
  • In binary, F is 1111, so FF is 11111111 — eight 1-bits, the largest unsigned byte.

FF (hex) = 255 (decimal) = 11111111 (binary)

Web Colors

What decimal RGB does #FF0000 represent?

A CSS color like #FF0000 packs three bytes — red, green, blue — into six hex digits. Converting back to decimal recovers the familiar 0–255 RGB triplet that paint apps and image editors display.

  • Split the six digits into three pairs: FF, 00, 00.
  • Red = FF = 255. Green = 00 = 0. Blue = 00 = 0.
  • So #FF0000 is rgb(255, 0, 0) — fully saturated red with no green or blue.

#FF0000 = rgb(255, 0, 0)

Memory

How many bytes is the hex value DEADBEEF?

Programmers sometimes initialize memory to a recognizable pattern like DEADBEEF so uninitialized reads stand out in a hex dump. Counting digits is the fast way to find its byte width.

  • DEADBEEF has 8 hex characters.
  • Every 2 hex digits represent 1 byte, so 8 ÷ 2 = 4 bytes.
  • That's the width of a 32-bit value — exactly one register on a 32-bit CPU.
  • Its decimal value is 15 × 16⁷ + 14 × 16⁶ + 10 × 16⁵ + 13 × 16⁴ + 11 × 16³ + 14 × 16² + 14 × 16 + 15 = 3,735,928,559.

DEADBEEF = 4 bytes = 3,735,928,559 (decimal)

Related Calculators

Related Sites