EasyUnitConverter.com

Hex Calculator

Perform arithmetic operations in Hexadecimal number system. Enter two hexadecimal numbers and select an operation.

About Hex Calculator

The Hexadecimal Calculator allows you to perform addition, subtraction, multiplication, and division operations directly in the hexadecimal number system without converting to decimal first.

How the Hexadecimal Calculator Works

A hexadecimal calculator performs arithmetic operations on base-16 numbers. Hexadecimal uses digits 0–9 and letters A–F (where A=10, B=11, C=12, D=13, E=14, F=15). Hex arithmetic carries at 16 instead of 10. This calculator accepts two hex values, performs the selected operation (+, −, ×, ÷), and returns the result in hexadecimal.

  1. Enter two hexadecimal numbers (digits 0–9 and A–F)
  2. Select an operation: addition, subtraction, multiplication, or division
  3. The result is displayed in hexadecimal format

Hexadecimal Arithmetic Rules

Addition: Add digit values. If sum ≥ 16, write (sum − 16) and carry 1.

Example: A + 7 = 10 + 7 = 17 → write 1, carry 1

Subtraction: If top digit < bottom digit, borrow 16 from next column.

Example: 3 − 8 → borrow to get 19 − 8 = B (11)

Multiplication: Multiply digit values, carry quotient when product ≥ 16.

Division: Long division in base-16.

Worked Example: FF + 1

FF (255 in decimal)

+ 1 (1 in decimal)

----

Column 0: F + 1 = 15 + 1 = 16 → write 0, carry 1

Column 1: F + carry 1 = 15 + 1 = 16 → write 0, carry 1

Column 2: carry 1

Result: 100₁₆ = 256₁₀

Verification: 255 + 1 = 256 ✓

Technical Details

Hexadecimal arithmetic is essential in low-level programming, memory address calculations, and color manipulation. When working with memory offsets, programmers frequently add hex addresses: a base address of 0x1000 plus an offset of 0x2F gives 0x102F. In CSS color math, adjusting brightness involves hex addition/subtraction on RGB channels. This calculator performs integer arithmetic with floor division. Input is case-insensitive — "ff" and "FF" are treated identically.

Frequently Asked Questions

What is FF + FF in hex?

FF + FF = 1FE. In decimal: 255 + 255 = 510, and 510 in hex is 1FE.

How do you subtract hex numbers?

Subtract digit by digit from right to left. If a digit in the top number is smaller than the bottom, borrow 16 from the next column. For example, 100 − 1 = FF (256 − 1 = 255).

Why is hex used for memory addresses?

Because each hex digit represents exactly 4 bits, making it compact and directly mappable to binary. A 32-bit address is just 8 hex digits (e.g., 0x7FFF0000), compared to 32 binary digits.

What is hex multiplication used for?

Hex multiplication appears in computing when calculating memory sizes (e.g., 0x400 × 0x400 = 0x100000, which is 1024 × 1024 = 1,048,576 bytes = 1 MB) and in cryptographic hash computations.

How to Perform Hexadecimal Arithmetic (Add, Subtract, Multiply, Divide in Base-16)

Hexadecimal arithmetic is used by programmers for memory address calculations, color math, checksum verification, and byte manipulation. The operations follow the same rules as decimal arithmetic but use base-16 digits (0-9, A-F). Carries and borrows happen at 16 instead of 10.

  1. Hex Addition: Add digits column by column. When the sum ≥ 16, subtract 16 and carry 1 to the next column.
  2. Hex Subtraction: Subtract column by column. If a digit is smaller than the one below, borrow 16 from the next column.
  3. Hex Multiplication: Multiply each hex digit, carry when product ≥ 16, shift and add partial products.
  4. Hex Division: Use long division with base-16 — determine how many times the divisor fits into partial dividends.
  5. Remember: A=10, B=11, C=12, D=13, E=14, F=15 when doing arithmetic.
💡 Tip: For quick hex addition: convert to decimal mentally, add, then convert back. 0xA + 0x7 = 10 + 7 = 17 = 0x11 (1 carry 1). With practice, you will do this without the decimal step.

Hex Arithmetic: Common Operations

Frequently performed hex calculations in programming:

InputOutput
0xFF + 0x010x100
0x100 - 0x010xFF
0x0A + 0x0A0x14
0x10 × 0x100x100
0xFF × 0x020x1FE
0x100 ÷ 0x100x10
0x80 + 0x800x100
0xFFFF + 0x10x10000
0xC0 + 0x400x100
0xDEAD + 0x00010xDEAE

Solved Examples: Hex Arithmetic

Question 1: Add hex 0x3F7 and 0x2A9.

Solution:

Column 0: 7 + 9 = 16 → write 0, carry 1

Column 1: F + A + 1 = 15 + 10 + 1 = 26 → 26-16=10=A, carry 1

Column 2: 3 + 2 + 1 = 6

Result: 0x6A0

Answer: 0x3F7 + 0x2A9 = 0x6A0 (1015 + 681 = 1696 ✓).

Question 2: Calculate the offset: 0x1000 - 0x0C80.

Solution:

Column 0: 0 - 0 = 0

Column 1: 0 - 8 → borrow: 16 - 8 = 8, borrow from column 2

Column 2: 0 - C - 1(borrow) → borrow: 16 - 13 = 3, borrow from column 3

Column 3: 1 - 0 - 1(borrow) = 0

Result: 0x0380

Answer: 0x1000 - 0x0C80 = 0x0380 (4096 - 3200 = 896 ✓).

Question 3: Multiply 0x1F by 0x03.

Solution:

F × 3 = 15 × 3 = 45 = 2D (write D, carry 2)

1 × 3 = 3 + 2(carry) = 5

Result: 0x5D

Answer: 0x1F × 0x03 = 0x5D (31 × 3 = 93 ✓).

Question 4: Divide 0xF0 by 0x0C.

Solution:

0xF0 ÷ 0x0C = 240 ÷ 12 = 20

20 in hex = 0x14

Verify: 0x0C × 0x14 = 12 × 20 = 240 = 0xF0 ✓

Answer: 0xF0 ÷ 0x0C = 0x14 (240 ÷ 12 = 20).

Practice: Hex Arithmetic

Try solving these on your own to test your understanding:

  1. Add 0xAB + 0xCD. (Answer: 0x178, which is 171+205=376)
  2. Subtract 0x100 - 0x7F. (Answer: 0x81, which is 256-127=129)
  3. Multiply 0x0F × 0x0F. (Answer: 0xE1, which is 15×15=225)
  4. Divide 0x80 ÷ 0x10. (Answer: 0x8, which is 128÷16=8)
  5. Add 0xFFFF + 0x0001. (Answer: 0x10000, which is 65535+1=65536)
  6. Subtract 0xBEEF - 0x0001. (Answer: 0xBEEE)

Hex Math in Memory Address Calculations

Programmers add hex offsets to base addresses constantly: if a struct starts at 0x7FFE0000 and a field is at offset 0x2C, the field address is 0x7FFE002C. Stack frames grow downward: ESP = 0x0028FF00, push 4 bytes → ESP = 0x0028FEFC (subtract 4). Page tables use 0x1000 (4096) alignment — any address ending in 000 is page-aligned. These calculations are fastest in hex because the patterns are visible.

Color Math: Blending with Hex Arithmetic

Mixing two colors at 50% means averaging their hex channels: (#FF0000 + #0000FF) / 2 → R=(FF+00)/2=7F, G=00, B=(00+FF)/2=7F → #7F007F (purple). Darkening a color: multiply each channel by a factor < 1. Lightening: blend toward #FFFFFF. CSS filter functions do this automatically, but understanding the hex arithmetic helps when writing custom shader code or canvas manipulations.

Key Takeaways

  • Hex addition carries at 16: if sum ≥ 16, subtract 16 and carry 1.
  • A+1=B, F+1=10, 9+1=A — learn the transitions around 10 and 16.
  • Memory offset math: base + offset = absolute address.
  • Color blending is per-channel hex arithmetic: average for 50% blend.
  • Overflow: 0xFF + 0x01 = 0x100 (byte boundary), 0xFFFF + 1 = 0x10000 (16-bit boundary).
  • Converting to decimal for complex operations, then back, is perfectly valid.

Related Number System Converters: