Use this free hex calculator to add, subtract, multiply, and divide hexadecimal numbers and to convert between hex, decimal, binary, and octal. It also supports bitwise operations (AND, OR, XOR, NOT, and shifts) and shows two’s complement values. Enter your numbers with or without the 0x prefix and get instant results with the steps. No signup needed.
Enter hexadecimal digits (0–9, A–F), with or without 0x.
For NOT, only the first number is used.
Bit width controls NOT and two's complement results.
| 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 |
Hexadecimal is a base-16 number system using digits 0–9 and letters A–F. Each hexadecimal digit represents four binary bits. Calculations use exact integer arithmetic.
For Arithmetic
Hexadecimal (hex) is a base-16 number system. It uses 16 symbols: the digits 0 to 9 and the letters A to F, where A to F stand for the values 10 to 15.
| Hex digit | 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 |
Each hex digit represents exactly 4 bits (a nibble), so two hex digits make one byte. That’s why hex is so popular in computing: it’s a compact, readable way to write binary data.
| Position | Power | Value |
|---|---|---|
| 1st (rightmost) | 16⁰ | 1 |
| 2nd | 16¹ | 16 |
| 3rd | 16² | 256 |
| 4th | 16³ | 4,096 |
| 5th | 16⁴ | 65,536 |
| 6th | 16⁵ | 1,048,576 |
| 7th | 16⁶ | 16,777,216 |
| 8th | 16⁷ | 268,435,456 |
| 9th | 16⁸ | 4,294,967,296 |
Multiply each digit by its power of 16 and add the results.
Divide repeatedly by 16 and read the remainders from bottom to top.
So 255 = 0xFF.
Replace each hex digit with its 4-bit binary value.
Group the bits in fours from the right, then convert each group.
0x2F + 0x1B
0x1A3F + 0x0BC1 = 0x2600 (decimal 6,719 + 3,009 = 9,728)
0xA5 − 0x3C
0xABC − 0x123 = 0x999 (decimal 2,748 − 291 = 2,457)
0x1F × 0xA = 0x136 (decimal 31 × 10 = 310)
0xDEAD × 0x2 = 0x1BD5A
0xFF ÷ 0x10 = 0xF remainder 0xF (decimal 255 ÷ 16 = 15 remainder 15)
Bitwise operations work on the individual bits of two numbers.
| Operation | Rule |
|---|---|
| AND | 1 only if both bits are 1 |
| OR | 1 if either bit is 1 |
| XOR | 1 if the bits are different |
| NOT | flips every bit |
| Shift left (<<) | moves bits left, multiplying by 2 for each place |
| Shift right (>>) | moves bits right, dividing by 2 for each place |
| Binary | Hex | |
|---|---|---|
| 0xF0 | 1111 0000 | F0 |
| 0x3C | 0011 1100 | 3C |
| AND | 0011 0000 | 0x30 |
| OR | 1111 1100 | 0xFC |
| XOR | 1100 1100 | 0xCC |
Computers store negative integers using two’s complement. In a signed 8-bit number, values from 0x80 to 0xFF are negative.
| 8-bit hex | Unsigned | Signed |
|---|---|---|
| 0x7F | 127 | 127 (largest positive) |
| 0x80 | 128 | −128 (smallest negative) |
| 0xFE | 254 | −2 |
| 0xFF | 255 | −1 |
To find the two’s complement, invert the bits and add 1 (or compute 2ⁿ minus the value).
| Hex | Decimal | Where you’ll see it |
|---|---|---|
| 0xFF | 255 | Largest unsigned byte |
| 0x100 | 256 | 2⁸ |
| 0x400 | 1,024 | 1 kibibyte |
| 0x1000 | 4,096 | A common memory page size |
| 0xFFFF | 65,535 | Largest unsigned 16-bit value |
| 0x7FFFFFFF | 2,147,483,647 | Largest signed 32-bit integer |
| 0xFFFFFFFF | 4,294,967,295 | Largest unsigned 32-bit value |
| 0xDEADBEEF | 3,735,928,559 | A well-known placeholder value used by programmers |
| 0xF4240 | 1,000,000 | One million |
As a result, the ratio between rent and income remains the same for every individual (approximately 26.7%), which may be perceived as fair when incomes vary significantly.
A hex color has the form #RRGGBB, with two hex digits each for red, green, and blue (0 to 255).
Each character has a numeric code. In hex: A = 0x41, a = 0x61, 0 = 0x30. The word “Hello” is 48 65 6C 6C 6F.
The IPv4 address 192.168.1.1 equals C0 A8 01 01 in hex, or 0xC0A80101.
A tool that performs math on hexadecimal (base-16) numbers and converts between hex, decimal, binary, and other bases.
Multiply each hex digit by its power of 16 and add the results. For 0x1A3F, the result is 4,096 + 2,560 + 48 + 15 = 6,719.
Divide the number repeatedly by 16 and read the remainders from bottom to top. For 255, you get 15 remainder 15, which is FF.
Replace each hex digit with its 4-bit binary value. A7 becomes 1010 0111.
Add digit by digit from the right. If a digit sum is 16 or more, write the remainder and carry 1. For example, 2F + 1B = 4A.
It marks a number as hexadecimal in many programming languages. 0xFF means hex FF, which is 255.
Each hex digit equals exactly four bits, so hex is a short, readable way to write binary data such as bytes and memory addresses.
It’s the largest value that fits in one unsigned byte.
The standard way computers store signed integers. In an 8-bit number, 0xFF is −1 and 0x80 is −128.
Yes, using two’s complement for the chosen bit width, or with a minus sign for plain hex arithmetic.
Decimal is base 10 with digits 0 to 9. Hex is base 16 with digits 0 to 9 and A to F.
Yes. It’s free, with no registration and no limits.
It uses exact integer arithmetic for the values you enter. Very large numbers are limited by the bit width you choose.
A few of the most-used tools in each hub.
This calculator is for general informational and educational purposes. Results depend on the numbers and bit width you enter. Check important calculations independently, especially for programming, security, or hardware work.