Skip to content
CALCULATORPRO — Free Online Calculators

Hex Calculator — Free Base-16 Converter and Math Tool

Add, subtract, multiply, and divide hexadecimal numbers, then convert between hex, decimal, binary, and octal instantly for coding and debugging.

ByEditorial Team, Math Updated Jun 7, 20262026 verified Methodology

About this calculator

About the Hex Calculator

Hexadecimal (base-16) is the preferred number system for programmers, web developers, and digital designers. Unlike binary's long strings of 0s and 1s, hex compresses data into a more readable format while maintaining a direct relationship with binary (each hex digit represents exactly 4 bits).

Our hex calculator lets you:

  • Perform arithmetic: Addition, subtraction, multiplication, and division in hex
  • Convert bases: Hex ↔ Decimal ↔ Binary ↔ Octal
  • Work with colors: Convert RGB values to hex color codes
  • Debug memory: Calculate memory addresses and offsets

Understanding Hexadecimal

Hex uses 16 digits: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15).

Hex Decimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111

Hex Addition

Add digit by digit, carrying when the sum reaches 16:

Example: A3F + 2B5

  ¹ ¹   (carries)
   A3F  (2623 in decimal)
 + 2B5  (693 in decimal)
 -----
   CF4  (3316 in decimal)

Step by step:

  • F(15) + 5 = 20 → 20 - 16 = 4, carry 1
  • 3 + B(11) + 1(carry) = 15 → F, carry 0
  • A(10) + 2 = 12 → C

Hex Subtraction

Example: CF4 - A3F

   CF4  (3316 in decimal)
 - A3F  (2623 in decimal)
 -----
   2B5  (693 in decimal)

Converting Hex to Decimal

Multiply each digit by 16 raised to its position power:

Example: Convert 2A7F to decimal

  • 2 × 16³ = 2 × 4096 = 8192
  • A(10) × 16² = 10 × 256 = 2560
  • 7 × 16¹ = 7 × 16 = 112
  • F(15) × 16⁰ = 15 × 1 = 15
  • Total: 8192 + 2560 + 112 + 15 = 10,879

Converting Decimal to Hex

Divide by 16 repeatedly and record remainders:

Example: Convert 3500 to hex

  • 3500 ÷ 16 = 218 remainder C(12)
  • 218 ÷ 16 = 13 remainder A(10)
  • 13 ÷ 16 = 0 remainder D(13)

Read remainders bottom to top: DAC

Hex in Web Development: Color Codes

CSS color codes use hex to represent RGB values:

Color Hex Code RGB
Red #FF0000 rgb(255, 0, 0)
Green #00FF00 rgb(0, 255, 0)
Blue #0000FF rgb(0, 0, 255)
White #FFFFFF rgb(255, 255, 255)
Black #000000 rgb(0, 0, 0)
Gray #808080 rgb(128, 128, 128)

Example: Convert rgb(173, 216, 230) to hex

  • 173 = AD
  • 216 = D8
  • 230 = E6
  • Result: #ADD8E6 (light blue)

Real-World Hex Applications

Application Example
Memory addresses 0x7FFF5E2C (RAM location)
MAC addresses 00:1A:2B:3C:4D:5E
IPv6 addresses 2001:0db8:85a3::8a2e:0370:7334
Unicode U+1F600 (😀 emoji)
Error codes 0x80070005 (Windows access denied)
File signatures 0x89504E47 (PNG file header)
Assembly language MOV AX, 0x4C00

Hexadecimal Notation

Different languages and systems denote hex differently:

Prefix/Suffix Used In
0x C, C++, Java, Python, JavaScript
&H Visual Basic
# HTML/CSS colors
$ Pascal, some assemblers
0h Some calculators
h suffix Assembly language

Frequently Asked Questions

Why do programmers prefer hex over binary?

Hex is more compact and readable. One hex digit represents 4 binary digits, so FF is much easier to read than 11111111.

What's the difference between hex and decimal?

Decimal is base-10 (digits 0-9) which humans use daily. Hex is base-16 (digits 0-9, A-F) which aligns perfectly with binary and is used in computing.

How many hex digits are in a byte?

A byte is 8 bits, which equals exactly 2 hex digits (since each hex digit = 4 bits).

What is the largest value in 32-bit hex?

FFFFFFFF = 4,294,967,295 (unsigned) or -1 (signed two's complement).

Can I use lowercase letters in hex?

Yes. a3f and A3F represent the same value. Uppercase is more common in programming.

Related Calculators

Comments

Sign in to leave a comment.

Loading comments…