Skip to main content

Calcu.fit

Hex Calculator: Hexadecimal Math and Conversions

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.

Hex Calculator

Hexadecimal calculator

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.

Hexadecimal result
4A
2F + 1B
Hexadecimal4A
Decimal74
Binary01001010
Octal112
Signed value74
Unsigned value74

Calculation steps

  1. 2F (47 decimal) + 1B (27 decimal) = 74
  2. 74 decimal = 4A hexadecimal

Number base converter

HexadecimalFF
Decimal255
Binary11111111
Octal377

Hexadecimal digit reference

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

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.

How to Use This Hex Calculator

For Arithmetic

  1. Enter the first hex number (for example, 2F or 0x2F).
  2. Choose an operation: add, subtract, multiply, or divide.
  3. Enter the second hex number.
  4. Click Calculate to see the result in hex, decimal, and binary.

For Conversions

  1. Choose the input base (hex, decimal, binary, or octal).
  2. Enter your number.
  3. See the equivalent in all the other bases.

For Bitwise Operations

  1. Enter two values (hex).
  2. Choose AND, OR, XOR, NOT, or a shift (<<, >>).
  3. Choose a bit width (8, 16, 32, or 64 bits) if you need two’s complement.

What You’ll See in Your Results

  • The answer in hex, decimal, binary, and octal
  • Step-by-step working for conversions and arithmetic
  • Quotient and remainder for division
  • Signed and unsigned values for the chosen bit width

What Is Hexadecimal?

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 digitDecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

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.

Powers of 16

PositionPowerValue
1st (rightmost)16⁰1
2nd16¹16
3rd16²256
4th16³4,096
5th16⁴65,536
6th16⁵1,048,576
7th16⁶16,777,216
8th16⁷268,435,456
9th16⁸4,294,967,296

How to Convert Between Hex and Other Bases

Hex to Decimal

Multiply each digit by its power of 16 and add the results.

Example: 0x1A3F

  • 1 × 16³ = 1 × 4,096 = 4,096
  • A (10) × 16² = 10 × 256 = 2,560
  • 3 × 16¹ = 3 × 16 = 48
  • F (15) × 16⁰ = 15 × 1 = 15
  • Total: 4,096 + 2,560 + 48 + 15 = 6,719

Decimal to Hex

Divide repeatedly by 16 and read the remainders from bottom to top.

Example: 255

  • 255 ÷ 16 = 15 remainder 15 (F)
  • 15 ÷ 16 = 0 remainder 15 (F)
  • Reading upward: FF

So 255 = 0xFF.

Hex to Binary

Replace each hex digit with its 4-bit binary value.

Example: 0xA7

  • A = 1010
  • 7 = 0111
  • Result: 1010 0111

Binary to Hex

Group the bits in fours from the right, then convert each group.

Example: 1101 0110 1010

  • 1101 = D
  • 0110 = 6
  • 1010 = A
  • Result: 0xD6A

Hex Arithmetic Examples

Addition

0x2F + 0x1B

  • F (15) + B (11) = 26 = 1A, so write A and carry 1
  • 2 + 1 + carry 1 = 4
  • Result: 0x4A (decimal 47 + 27 = 74)

0x1A3F + 0x0BC1 = 0x2600 (decimal 6,719 + 3,009 = 9,728)

Subtraction

0xA5 − 0x3C

  • 5 − C: borrow 16, so 21 − 12 = 9
  • A (after the borrow, 9) − 3 = 6
  • Result: 0x69 (decimal 165 − 60 = 105)

0xABC − 0x123 = 0x999 (decimal 2,748 − 291 = 2,457)

Multiplication

0x1F × 0xA = 0x136 (decimal 31 × 10 = 310)

0xDEAD × 0x2 = 0x1BD5A

Division

0xFF ÷ 0x10 = 0xF remainder 0xF (decimal 255 ÷ 16 = 15 remainder 15)

Bitwise Operations

Bitwise operations work on the individual bits of two numbers.

OperationRule
AND1 only if both bits are 1
OR1 if either bit is 1
XOR1 if the bits are different
NOTflips every bit
Shift left (<<)moves bits left, multiplying by 2 for each place
Shift right (>>)moves bits right, dividing by 2 for each place

Example: 0xF0 and 0x3C

 BinaryHex
0xF01111 0000F0
0x3C0011 11003C
AND0011 00000x30
OR1111 11000xFC
XOR1100 11000xCC

More examples:

  • NOT 0x0F (8-bit) = 0xF0
  • 0xFF << 4 = 0xFF0 (shifting left by 4 bits adds one hex digit)
  • 0xFF >> 4 = 0xF
  • 1 << 8 = 0x100 (256)

Two’s Complement (Negative Numbers)

Computers store negative integers using two’s complement. In a signed 8-bit number, values from 0x80 to 0xFF are negative.

8-bit hexUnsignedSigned
0x7F127127 (largest positive)
0x80128−128 (smallest negative)
0xFE254−2
0xFF255−1

Converting a negative number to hex:

  • −10 in 8 bits = 0xF6
  • −255 in 16 bits = 0xFF01
  • −1 in 32 bits = 0xFFFFFFFF

To find the two’s complement, invert the bits and add 1 (or compute 2ⁿ minus the value).

Common Hex Values

HexDecimalWhere you’ll see it
0xFF255Largest unsigned byte
0x1002562⁸
0x4001,0241 kibibyte
0x10004,096A common memory page size
0xFFFF65,535Largest unsigned 16-bit value
0x7FFFFFFF2,147,483,647Largest signed 32-bit integer
0xFFFFFFFF4,294,967,295Largest unsigned 32-bit value
0xDEADBEEF3,735,928,559A well-known placeholder value used by programmers
0xF42401,000,000One 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.

Where Hexadecimal Is Used

Web Colors

A hex color has the form #RRGGBB, with two hex digits each for red, green, and blue (0 to 255).

  • #FF5733 → red 0xFF = 255, green 0x57 = 87, blue 0x33 = 51 → rgb(255, 87, 51)
  • #1E90FF → rgb(30, 144, 255)

Computing and Networking

  • Memory addresses and pointers in debuggers and low-level code
  • Machine code and file bytes shown in hex editors
  • MAC addresses (for example, 00:1A:2B:3C:4D:5E) and IPv6 addresses
  • Cryptographic hashes and keys
  • Color codes, Unicode code points, and character encodings

Text and ASCII

Each character has a numeric code. In hex: A = 0x41, a = 0x61, 0 = 0x30. The word “Hello” is 48 65 6C 6C 6F.

IP Addresses

The IPv4 address 192.168.1.1 equals C0 A8 01 01 in hex, or 0xC0A80101.

Tips for Working With Hex

  1. Memorize A to F: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
  2. Think in groups of four bits. One hex digit is one nibble.
  3. Remember that 0xFF is 255 and 0x10 is 16, not ten.
  4. Watch the carries. In hex addition, you carry when a digit sum reaches 16.
  5. Pad with leading zeros to keep a fixed width (for example, 0x0A in a byte).
  6. Check the bit width when working with negative numbers or overflow.
  7. Be careful with case. Hex letters are usually case-insensitive (0xff and 0xFF are the same), but some systems expect one style.

Hex Calculator vs. Other Tools

  • Binary calculator: convert and perform calculations in binary, decimal, and hexadecimal systems.
  • Scientific calculator: advanced mathematical functions.
  • Prime factorization calculator: break down numbers into their prime factors.
  • Roman numeral converter: convert between Roman numerals and numbers.
  • Scientific notation calculator: work with very large and very small numbers.
  • Percentage calculator: calculate percentages of a number and determine percentage changes.

Frequently Asked Questions (FAQ)

What is a hex calculator?

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.

Disclaimer

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.