Hex Calculator

Hex Calculator

Popular AI Skill PRO

Enter Calculation

Formula

Result16=⌊Hex1Hex2⌋\text{Result}_{16} = \left\lfloor \frac{{{\text{Hex}_1}}}{{{\text{Hex}_2}}} \right\rfloor
Usage stats

Advertisement

Results

Operation FF ÷ 10
Hex Result F
Decimal Values 255 ÷ 16
Decimal Result 15

Report an error on this page

What the Hex Calculator Does

The Hex Calculator performs arithmetic directly on hexadecimal (base-16) numbers. Instead of converting to decimal by hand, doing the math, and converting back, you simply enter two hex values, pick an operation, and get the answer in hex. It supports addition, subtraction, multiplication, and division, making it handy for programmers, embedded engineers, and anyone working with memory addresses, color codes, or byte-level data.

The Input Fields

  • Hex Value 1: Your first hexadecimal number (digits 0–9 and letters A–F).
  • Operation: Choose Add, Subtract, Multiply, or Divide.
  • Hex Value 2: Your second hexadecimal number.

How the Calculation Works

Behind the scenes, both hex strings are parsed into whole numbers (base 16 to base 10). The chosen operation is applied, then the result is converted back to uppercase hexadecimal. In formula terms:

  • Add: \( \text{Result}_{16} = \text{Hex}_1 + \text{Hex}_2 \)
  • Subtract: \( \text{Result}_{16} = \text{Hex}_1 - \text{Hex}_2 \)
  • Multiply: \( \text{Result}_{16} = \text{Hex}_1 \times \text{Hex}_2 \)
  • Divide: \( \text{Result}_{16} = \left\lfloor \frac{\text{Hex}_1}{\text{Hex}_2} \right\rfloor \) (whole-number division, the remainder is dropped)

Because the math uses big-integer arithmetic, it handles very large hex values without overflow. If you divide by zero (Hex Value 2 = 0), the calculator returns "Error" since division by zero is undefined.

Advertisement
Diagram of hexadecimal place values mapped to powers of sixteen
Each hex digit represents a power of 16, which is how the calculator converts and computes values.

Worked Example

Suppose you enter Hex Value 1 = 1A, choose Multiply, and enter Hex Value 2 = F.

  • 1A in decimal = 26
  • F in decimal = 15
  • \( 26 \times 15 = 390 \)
  • 390 back to hex = 186

So $$ 1A \times F = 186 $$ in hexadecimal. The calculator shows you both the hex result and the underlying decimal values so you can double-check.

Column-aligned hexadecimal addition with a carry and result
A column-by-column hex addition showing how carries propagate to the result.

Hex, Decimal, and Binary Conversion Table

Hexadecimal is a base-16 numbering system: it uses the ten digits 0–9 plus the six letters A–F to represent the values ten through fifteen. Because \(16 = 2^4\), every single hex digit maps exactly onto four binary bits (a nibble), which is why hex is the standard shorthand for binary data in computing worldwide.

Single hex digits: decimal and 4-bit binary equivalents
Hex Decimal Binary (4-bit)
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

Place values grow by a factor of 16 from right to left, exactly as decimal places grow by 10:

Hex place values
Position (from right) Power Decimal value
1st \(16^0\) 1
2nd \(16^1\) 16
3rd \(16^2\) 256
4th \(16^3\) 4096
5th \(16^4\) 65536

So a four-digit hex number is read as

$$N = d_3 \times 16^3 + d_2 \times 16^2 + d_1 \times 16 + d_0$$

The following landmark values appear constantly in programming, memory maps, and file formats:

Common hex landmarks
Hex Decimal Binary Meaning
0xFF 255 11111111 Largest 8-bit (1-byte) unsigned value
0x100 256 1 0000 0000 One more than a full byte; 28
0x3E8 1000 11 1110 1000 Decimal one thousand
0xFFFF 65535 sixteen 1s Largest 16-bit (2-byte) unsigned value
0x10000 65536 1 followed by sixteen 0s 216; one 64 KiB block
0xFFFFFFFF 4294967295 thirty-two 1s Largest 32-bit (4-byte) unsigned value

Notice the pattern: \(n\) hex digits of F equal \(16^n - 1\), and each added hex digit multiplies the range by 16 (adds 4 bits).

How to Do Hex Arithmetic by Hand

Every hex operation follows the same skeleton: check the digits, work in a base you can handle, then present the answer back in base 16. The steps below match what the calculator does internally.

  1. Validate the digits. Each character must be 0–9 or A–F (case does not matter; a = A = 10). Any other character — G, a space in the middle, a stray comma — makes the value invalid. A leading 0x prefix or trailing h is just notation and is stripped before calculating.
  2. Expand each digit by its power of 16 to get a decimal value you can reason about. For example:
    \(2F_{16} = 2 \times 16 + 15 = 32 + 15 = 47_{10}\)
    \(1A7_{16} = 1 \times 256 + 10 \times 16 + 7 = 256 + 160 + 7 = 423_{10}\)
  3. Add or subtract column by column, right to left. Work in hex directly if you prefer: when a column total reaches 16 or more, write down the total minus 16 and carry 1 into the next column; when subtracting and the top digit is smaller, borrow from the next column to the left — that borrow is worth 16, not 10.
  4. For multiplication and division, convert to decimal, compute, and convert back. Long multiplication in base 16 requires a 16×16 times table, so converting is faster and far less error-prone by hand. This calculator performs integer (truncating) division: the quotient is truncated toward zero and the remainder is discarded, and dividing by \(0_{16}\) is undefined.
  5. Convert the decimal answer back to hex by repeated division by 16, reading the remainders from the bottom up. For 390:
    \(390 \div 16 = 24\) remainder \(6\)
    \(24 \div 16 = 1\) remainder \(8\)
    \(1 \div 16 = 0\) remainder \(1\)
    Reading the remainders bottom-up gives \(186_{16}\). Check: \(1 \times 256 + 8 \times 16 + 6 = 390\). Remainders of 10–15 are written as A–F.

Worked example: addition

Add \(2F_{16} + 1A7_{16}\).

  1. Rightmost column: \(F + 7 = 15 + 7 = 22\). Since \(22 \ge 16\), write \(22 - 16 = 6\) and carry 1.
  2. Middle column: \(2 + A + 1_{\text{carry}} = 2 + 10 + 1 = 13 = D\), no carry.
  3. Left column: only \(1\) remains, so it comes straight down.

The result is 1D616. Decimal check: \(47 + 423 = 470\), and \(1 \times 256 + 13 \times 16 + 6 = 256 + 208 + 6 = 470\). ✓

Worked example: subtraction with a borrow

Compute \(200_{16} - 1A_{16}\). In decimal that is \(512 - 26 = 486\). Digit by digit: \(0 - A\) needs a borrow, and because the neighbouring digit is also 0 the borrow cascades from the leading 2, giving columns \(1, F, 16-10=6\) → \(1E6_{16}\). Check: \(256 + 14 \times 16 + 6 = 256 + 224 + 6 = 486\). ✓

Worked example: truncating division

Divide \(FF_{16} \div 10_{16}\). Convert: \(255 \div 16 = 15.9375\). Integer division truncates to 15, and \(15_{10} = F_{16}\), so the answer is F16 — the remainder of 15 is discarded. A useful shortcut: dividing by \(10_{16}\) simply drops the last hex digit, just as dividing by 10 drops the last digit in decimal.

Worked example: multiplication

Compute \(2F_{16} \times 10_{16}\). In decimal, \(47 \times 16 = 752\). Converting back: \(752 \div 16 = 47\) r \(0\); \(47 \div 16 = 2\) r \(15 = F\); \(2 \div 16 = 0\) r \(2\) → \(2F0_{16}\). Multiplying by \(10_{16}\) appends a zero digit, exactly as multiplying by 10 does in decimal.

Advertisement

Key Hex Terms Defined

Term Definition
Hexadecimal (hex) The base-16 numbering system, using the sixteen symbols 0–9 and A–F. Each position is worth 16 times the position to its right.
Base / radix The number of distinct digits a system uses. Decimal has radix 10, binary radix 2, hex radix 16. A subscript such as \(1D6_{16}\) states the radix explicitly.
Hex digit One symbol of a hex number, representing a value from 0 to 15. A, B, C, D, E, F stand for 10, 11, 12, 13, 14, 15.
Nibble Four bits — exactly one hex digit, with 16 possible values (0–F).
Byte Eight bits — exactly two hex digits, covering 0x00 to 0xFF (0 to 255 unsigned).
Word The natural unit of data for a given processor or format. Its size varies by architecture: commonly 16 bits (4 hex digits), but 32 or 64 bits elsewhere. Always check which definition a given document or CPU manual uses.
0x prefix The C-language style marker for a hex literal, as in 0x1F. It is notation only and adds nothing to the value.
Trailing h The assembly-language convention for the same thing, as in 1Fh. Other conventions include $1F, #1F, and 16#1F#.
Most significant digit (MSD) The leftmost digit — the one carrying the largest place value, and therefore the one that changes the number the most.
Least significant digit (LSD) The rightmost digit, worth \(16^0 = 1\).
Carry In addition, the 1 passed to the next column left when a column total reaches 16 or more.
Borrow In subtraction, the unit taken from the next column left when the top digit is too small. In hex a borrow is worth 16.
Integer (floor) division Division that yields a whole-number quotient with the fractional part removed. For non-negative operands, truncating toward zero and flooring give the same answer; this calculator truncates toward zero.
Remainder / modulo What is left over after integer division: \(a - b \times (a \div b)\). For \(FF \div 10\) the remainder is \(F\) (15). This calculator discards it.
Overflow What happens when a result is too large for the storage width in use — e.g. adding 1 to a 32-bit 0xFFFFFFFF wraps around to 0x00000000 in fixed-width hardware arithmetic.
Big-integer arithmetic Software arithmetic on numbers of arbitrary length, limited by memory rather than by a fixed 32- or 64-bit register. It avoids overflow, which is why a calculator can handle hex values far longer than a CPU word.
Unsigned representation An encoding in which every bit pattern is a non-negative value: an 8-bit byte ranges 0x00–0xFF, i.e. 0 to 255.
Signed representation An encoding that reserves part of the range for negative values. The same 8-bit patterns then span −128 to +127, so 0xFF means −1 rather than 255. Whether a hex string is signed depends entirely on how the surrounding program interprets it.
Two's complement The near-universal way to encode signed integers: negate a value by inverting all bits and adding 1. In 8 bits, \(-1\) is 0xFF and \(-128\) is 0x80. It lets one adder circuit handle both addition and subtraction.
Memory address A location in memory, conventionally written in hex (e.g. 0x7FFF0000) because hex maps cleanly onto address bits and page boundaries.
#RRGGBB color code The web/CSS notation where three pairs of hex digits give the red, green, and blue channels, each 0x00–0xFF. #FF0000 is pure red; #FFFFFF is white; #000000 is black.

Two practical notes when using these terms with any hex calculator: results here are treated as plain mathematical integers, not as fixed-width machine values, so no wrap-around overflow occurs; and division returns only a truncated quotient, so if you need the remainder as well you must compute it separately.

Frequently Asked Questions

Does division give a fraction or remainder? No. Division returns the integer quotient only — for example, 10 ÷ 3 (hex) yields the whole-number result, and any remainder is discarded.

Can I use lowercase hex letters? Yes. Hex parsing accepts both lowercase (a–f) and uppercase (A–F). The result is always displayed in uppercase.

What if subtraction produces a negative number? The calculator handles it correctly and will display a negative hex result, since it works with signed big-integer values.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators