Skip to content
CalcTide logo
Tech

Hex Calculator

0x1F + 0x0A = 0x29, which is 41 in decimal. That is the kind of quick check this hex calculator is built for. Enter two hexadecimal values, choose add, subtract, multiply, or divide, and the tool returns both the hex result and the decimal interpretation of each input. It is useful when you are working with byte values, memory offsets, masks, color channels, packet fields, or homework problems and want a fast answer without mentally converting every step. This version stays narrow on purpose. It handles whole-number hex arithmetic, accepts values with or without a 0x prefix, and shows division as an integer quotient.

TechBy

Quick answer

Hexadecimal is base 16, so each digit can be 0 through 9 or A through F, where A means 10 and F means 15.

What this tells you

  • •Hexadecimal is base 16, so each digit can be 0 through 9 or A through F, where A means 10 and F means 15.
  • •The calculator trims the input, removes one optional 0x prefix, and parses the remaining characters as a non-negative hex number.
  • •It converts both hex inputs to decimal, performs the selected arithmetic operation, then converts the result back to uppercase hex.
  • •The page shows the decimal value of A and B as well as the final result, which makes it easier to sanity-check your work when you are learning or debugging.
  • •Division in this tool returns the integer quotient only. If 0x7B is divided by 0x10, the decimal math is 123 divided by 16, which becomes 7, not 7.6875.
  • •Positive results print in full, with no 32-bit ceiling. A negative result that fits in a signed 32-bit integer prints as its 32-bit two's-complement pattern, so subtraction that goes below zero can produce a large wraparound-looking hex result even though the decimal result is negative.

How to Use

  1. 1Enter Hex A and Hex B using digits 0 through 9 and letters A through F. You can type uppercase or lowercase.
  2. 2Include the 0x prefix if you like, or leave it off. Both 1f and 0x1F are accepted.
  3. 3Choose the operation. Add and subtract are common for offsets and counters. Multiply is useful for block sizing. Divide is useful for quick quotient checks.
  4. 4Click calculate and read both outputs together. The hex result answers the base-16 question, while the decimal lines let you verify that the parser read your inputs the way you expected.
  5. 5For division, remember that this calculator gives the whole-number quotient only. If you need the remainder, use a remainder or long-division tool instead.
  6. 6If a result looks strange after subtraction, check the decimal line first. A negative decimal result can still appear as a large unsigned hex value because of how this tool formats hex output.
  7. 7Keep the inputs plain. Spaces inside the number, commas, signs, and separators are not supported here.

How It Works

Formula

decimalA = parseInt(hexA, 16) decimalB = parseInt(hexB, 16) resultDecimal = operation(decimalA, decimalB) for divide: resultDecimal = floor(decimalA / decimalB) r = resultDecimal, hex(n) = n.toString(16) in uppercase r >= 0: resultHex = 0x + hex(r) -2^31 <= r < 0: resultHex = 0x + hex(unsigned32(r)) r < -2^31: resultHex = -0x + hex(abs(r))

The calculator first strips one optional 0x prefix and validates that the rest of each input contains only hex digits. It then converts both values to decimal and runs the selected operation on whole numbers. Addition, subtraction, and multiplication behave the way you would expect from standard integer arithmetic. Division uses the integer quotient by applying floor to the decimal result, so any fractional part is discarded. After the decimal result is computed, the tool formats the hex output in uppercase. Zero and positive results print in full at any size. A negative result between -2,147,483,648 and -1 prints as its 32-bit two's-complement pattern, which is how that value would sit in a 32-bit register. A negative result below -2,147,483,648 has no 32-bit pattern, so it prints with a minus sign. That detail matters when the decimal answer is negative, because the decimal line and the hex line will no longer look like simple signed versions of each other.

Calculation note: values are processed in the order shown above, using the current input units.

Worked Examples

Register offset addition

A0x1F
B0x0A
OperationAdd
ResultResult 0x29, decimal 41

0x1F is 31 in decimal and 0x0A is 10. Add them and you get 41, which is 0x29 in hex. This is a common quick-check case when you are stepping through offsets or summing byte values by hand.

Simple subtraction that stays positive

A0x2C
B0x10
OperationSubtract
ResultResult 0x1C, decimal 28

0x2C equals 44 and 0x10 equals 16. Subtracting gives 28, which converts back to 0x1C. This is the cleanest kind of subtraction to verify in the tool because both the decimal and hex outputs stay intuitive.

Block size multiplication

A0x20
B0x08
OperationMultiply
ResultResult 0x100, decimal 256

0x20 is 32 and 0x08 is 8. Multiplying them gives 256, which is 0x100 in hex. Results like this come up in memory sizing, page calculations, and repeated unit scaling where powers of two are common.

Integer division for page counts

A0x7B
B0x10
OperationDivide
ResultResult 0x7, decimal 7

0x7B is 123 decimal and 0x10 is 16 decimal. Dividing 123 by 16 gives 7.6875, but this tool keeps only the integer quotient. That is why the displayed answer is 7, or 0x7 in hex. It is useful when you only care how many full chunks fit.

Scenario: Dana finds the end of a firmware table

Run 10x1000 + 0x3F8 (Add)
Run 20x3A8 / 0x40 (Divide)
ResultRun 1: 0x13F8, decimal 5112 | Run 2: 0xE, decimal 14

Dana is reading a firmware map. A configuration table starts at offset 0x1000 and is 0x3F8 bytes long, so the first byte after it is 0x1000 + 0x3F8 = 0x13F8, which the decimal line confirms as 4096 + 1016 = 5112. A second table is 0x3A8 bytes (936) and holds fixed 0x40-byte (64) records, so Dana divides and gets 0xE, or 14 full records. 936 divided by 64 is 14.625, and the tool drops the fraction, so the 40 leftover bytes are padding she needs to account for separately.

Hex, decimal, binary, and octal for the values you meet most often

The hex and decimal columns are what this calculator prints for each value (it does not zero-pad, so 15 shows as 0xF). Binary and octal come from the same base conversion the tool uses for hex.

Hex (as shown)DecimalBinaryOctalWhere it shows up
0xF15111117Largest value in one hex digit, one nibble of all ones
0x10161000020First carry into the second hex digit
0x7F1271111111177Largest signed 8-bit value
0x8012810000000200Sign bit of a byte, lowest value that needs 8 bits
0xFF25511111111377Largest unsigned byte, one color channel at full
0x100256100000000400First value that needs a second byte
0x40010241000000000020001 KiB, a common page and block size
0xFFFF655351111111111111111177777Largest unsigned 16-bit value, highest TCP port
0xFFFFFF167772151111111111111111111111117777777724-bit RGB white, #FFFFFF in CSS
0x7FFFFFFF2147483647111111111111111111111111111111117777777777Largest signed 32-bit value
0xFFFFFFFF42949672951111111111111111111111111111111137777777777Largest unsigned 32-bit value, also how this tool prints -1
0x100000000429496729610000000000000000000000000000000040000000000First value that needs 33 bits, what 0xFFFFFFFF + 0x1 prints

Hex and decimal cells are the tool's own output. Binary and octal use the same conversion, Number.prototype.toString with a radix of 2 or 8, specified in ECMA-262 (section Number.prototype.toString, radix 2 through 36). Negative results that fit in a signed 32-bit integer print as 32-bit two's-complement patterns: 0x10 minus 0x20 prints decimal -16 and hex 0xFFFFFFF0, and 0x0 minus 0x80 prints -128 and 0xFFFFFF80. Below -2,147,483,648 the hex line uses a minus sign instead, so 0x0 minus 0x100000000 prints -0x100000000.

What this hex calculator assumes

This tool assumes both inputs are non-negative whole numbers written in hexadecimal. It is not a signed integer simulator, a floating-point calculator, or a bitwise operations playground. If you need left shifts, AND masks, two's-complement interpretation by bit width, or arbitrary-precision math, you need a different tool than this one.

The divide operation is deliberately simple. It answers the question, how many whole times does B fit into A, and it drops any remainder. That is a useful behavior for chunk counts, page counts, block alignment checks, and classroom examples. It is not the same thing as full fractional division, and it does not expose the remainder separately.

Hex is base 16, and its real convenience is that one hex digit is exactly 4 bits, a nibble, so two hex digits are always one byte. 0xFF is 11111111 in binary and 255 in decimal, and 0x7F drops only the top bit to give 01111111, or 127. Octal groups bits in threes instead, which is why 255 is 377 in octal and why file permissions like 755 read naturally in that base. Decimal has no clean relationship to bits at all, which is why 0x400 feels round to a programmer (1024, ten bits) and 1000 does not.

You will meet hex in a few fixed places. CSS colors use the #RRGGBB form defined in the CSS Color Module Level 4 (section 5.2), where each pair of hex digits is one channel from 00 to ff, so #FF8000 is red 255, green 128, blue 0, and #FFFFFF is 0xFFFFFF, decimal 16,777,215. Memory addresses, register offsets, and file offsets in a hex dump are written in hex because each pair maps to a byte. MAC addresses are six bytes shown as twelve hex digits. Unicode code points like U+00E9 and most hash digests are hex too. In every case the arithmetic is the same base-16 work this page does.

Parsing and formatting follow ECMA-262. The tool strips an optional 0x and calls parseInt with a radix of 16, then formats the result with Number.prototype.toString(16), which accepts any radix from 2 to 36. That method writes a negative number with a leading minus sign, not as two's complement, so for a negative result that fits in a signed 32-bit integer the tool first applies an unsigned 32-bit view. That is why 0x10 minus 0x20 shows decimal -16 but hex 0xFFFFFFF0: the hex line is the 32-bit two's-complement pattern of -16. The decimal result line is the safest place to confirm the signed outcome.

Positive results have no 32-bit ceiling. 0xFFFFFFFF + 0x1 prints decimal 4294967296 and hex 0x100000000, and 0x10000 times 0x10000 gives the same answer. A negative result below -2,147,483,648 has no 32-bit pattern, so the hex line writes it with a minus sign: 0x0 minus 0x100000000 prints decimal -4294967296 and hex -0x100000000. Separately, ECMA-262 defines Number values as IEEE 754 double-precision, and Number.MAX_SAFE_INTEGER is 2^53 minus 1, or 9,007,199,254,740,991. Above that, integers lose exactness before the operation runs. For bytes, words, pages, offsets, and homework values this calculator is fine. For 64-bit identifiers or strict overflow behavior, use a BigInt-aware workflow instead.

Turn a hex color into RGB and HSL with the color converter

Common mistakes

  • Typing characters outside 0 through 9 and A through F. A value like 0x1G is not valid hex.
  • Assuming division returns a remainder or decimal fraction. This calculator only returns the integer quotient.
  • Expecting negative subtraction results to display as signed hex. The decimal line can be negative while the hex line shows a 32-bit two's-complement pattern, such as 0xFFFFFFF0 for -16.
  • Pasting values with spaces, underscores, commas, or sign characters. This parser accepts plain hex text and one optional 0x prefix only.
  • Mixing up decimal and hex place values. 0x10 is sixteen, not ten.
  • Using very large values and assuming JavaScript will keep every integer exact far beyond the safe range.

Embed this calculator on your site

Paste this code where you want the calculator to appear. It is responsive, mobile-friendly, resizes automatically, and is free to use as long as the credit line stays in place.

<script src="https://calctide.com/embed.js" data-tool="hex-calculator" async></script> <p style="font-size:12px;margin:4px 0 0">Hex Calculator by <a href="https://calctide.com/tech/hex-calculator/">CalcTide</a></p>

Preview the embed at /embed/hex-calculator/.

Frequently Asked Questions

Yes. The parser accepts uppercase or lowercase letters and strips one optional 0x prefix before converting the value. Inputs like ff, FF, and 0xFF all represent the same number in this tool.
Because 0xFF is 255 in decimal. Adding 1 gives 256, and 256 in hexadecimal is 0x100. This is the same kind of carry that turns 99 into 100 in base 10, just happening in base 16 instead.
No. This version returns the integer quotient only. For example, 0x7B divided by 0x10 becomes 7 because 123 divided by 16 is 7.6875 and the fractional part is discarded. If you need the remainder too, use a remainder-focused calculator.
Because a negative result that fits in 32 bits is shown as its 32-bit two's-complement pattern. The decimal line holds the signed answer, so negative 1 in decimal appears as 0xFFFFFFFF in hex. Results below -2,147,483,648 print with a minus sign instead, such as -0x100000000. That is a formatting rule of this tool, not a claim that the math stopped being negative.
Not reliably. The calculator does not let you choose a signed width or overflow rule, so it cannot model two's-complement behavior the way a CPU register would. It is best for straightforward non-negative integer arithmetic and quick base conversion checks.
No. Unlike some hex byte tools, this page expects each number as one continuous hex string, optionally with a single 0x prefix. Inputs like FF FF, FF_FF, or FF,FF are not valid here.
Any whole number up to 9,007,199,254,740,991 in decimal (0x1FFFFFFFFFFFFF) stays exact. The hex line prints positive results in full, with no 32-bit ceiling. Above that JavaScript safe integer limit, exact integer arithmetic is no longer guaranteed. If you are checking very large 64-bit values, use a BigInt-capable toolchain instead.
Read the decimal lines as well as the hex line. If A, B, and the result look right in decimal, you can trust that the parser understood your input and that the hex output is the corresponding base-16 representation used by this tool.
It estimates hex calculator outputs using the visible inputs and formula assumptions on this page.

Explore More in Tech