Hex Calculator
Result
Hexadecimal
- Decimal
- 10,842
- Binary
- 10101001011010
- Remainder
- 0
A hex calculator adds, subtracts, multiplies and divides hexadecimal numbers, and gives the answer in hexadecimal, decimal and binary. Hexadecimal is base sixteen, which means sixteen digit shapes are needed where decimal has ten — so the six that are missing are borrowed from the alphabet, and A through F stand for ten through fifteen. That is the whole of the notation: A is not a code or an abbreviation, it is the digit that comes after 9. The four operations are the familiar ones: addition, subtraction, multiplication and division run column by column exactly as decimal arithmetic does, with sixteen as the base rather than ten, so a column carries when it passes F rather than when it passes 9. The answer is given three times because the three readings serve different readers: the hexadecimal is what the value is usually written as, the decimal is the one most people can sanity-check, and the binary is the underlying bits, which is where the hexadecimal digits came from in the first place. Division is integer division, so a remainder gets its own row instead of a decimal point.
Formula
2A3F + 1B = 2A5A (10815 + 27 = 10842)
- 2A3F
- The first number, written in base sixteen. The letters are digits: A is ten, B is eleven, up to F for fifteen. Reading A as anything else is the mistake this page exists to prevent
- + − × ÷
- The operation. It runs column by column exactly as decimal arithmetic does, with sixteen as the base rather than ten, so a column carries once it passes F
- F + 1 = 10
- The carry rule in this base: fifteen plus one runs out of digits and starts a new column. It is the same event as 9 + 1 = 10 in decimal, one base further along
- sum of digit × 16ⁿ
- How the decimal reading is produced: each digit multiplied by its place value and the results added. It is how 2A3F comes out as 10815 — 8192 plus 2560 plus 48 plus 15
- 4 bits per digit
- Why this base is used at all. One hexadecimal digit holds exactly four binary digits, so a byte is exactly two of them and no arithmetic is needed to move between the two notations — only regrouping
- remainder
- What is left when a division does not come out exactly. The row is always present, and it reads 0 for the three operations that cannot leave one — a zero there means the operation left nothing over, not that the row failed to fill in
- 53 bits
- How wide an input this page accepts: up to 9007199254740991, which is 1FFFFFFFFFFFFF here — fourteen digits. Past that width a machine number can no longer tell its neighbours apart, and the arithmetic would quietly stop being exact
Hexadecimal is what binary looks like when a person has to read it. Anywhere a value is sixteen bits or wider — a memory address, a colour, a hash, a machine-code listing, a device register dump, a network packet capture — it is printed in this base, and doing arithmetic on those values is a daily task for anyone working at that level. Adding an offset to a pointer, working out the size of a struct, computing a checksum, stepping through an address range while debugging, or checking which bits a mask sets are all operations people do on hexadecimal numbers, and the binary reading next to the answer is what turns the result back into the flags and fields it represents. Designers and front-end developers meet it in colour values, where a two-digit pair per channel is exactly the byte the screen wants. The page is also used the other way round: a value known in decimal is converted to hexadecimal to be compared against a specification or pasted into a tool, and the binary reading answers the question of which bits are actually set. Students learning number bases get the same benefit, since the letters are the part that looks arbitrary until the place values are laid out.
Worked examples
Adding 2A3F and 1B
- Line the two numbers up on the right: 2A3F and 001B
- Rightmost column: F + B, which is 15 + 11 = 26 = 16 + 10, so write A and carry 1
- Next column: 3 + 1 + the carried 1 = 5, so write 5
- Next column: A + 0 = A, so write A
- Leftmost column: 2 + 0 = 2, so write 2
- The result reads 2A5A, which is 10842 in decimal
The default example, and the one that shows a carry crossing the letter boundary: F plus B is twenty-six, which is one sixteen and ten over, so the digit written down is A rather than a two-digit number. The binary reading is the same bits regrouped four at a time, which is a useful check on the whole thing.
Dividing 2A3F by 1B
- This is 10815 divided by 27
- 27 goes into 10815 four hundred times exactly, with 15 left over
- Four hundred is 190 in hexadecimal, and the remainder fifteen is F
- The page reports 190 with a remainder of F
The remainder here is F, which is fifteen — a value that needs a letter even though it is smaller than the divisor. It is also the example that makes the always-present remainder row worth its space: without it the answer would read 190, and 400 times 27 is 10800, not 10815.
The same sum in lower case
- Lower case and upper case letters are the same digits: a is ten exactly as A is
- The arithmetic is unchanged, so the answer is the same 2A5A
- The page prints its answer in capitals regardless of how the input was typed
Worth knowing because both conventions are in daily use — CSS colour values are almost always lower case, while disassemblers and data sheets print capitals — and neither is wrong. Only the printed answer is normalised, and it is normalised upwards.
Limitations
This page works on whole hexadecimal numbers only. There is no hexadecimal point and no fractional input, so 2A.8 is not accepted; a division that does not come out exactly gives a truncated quotient plus a remainder rather than a fractional answer. Inputs are limited to 1FFFFFFFFFFFFF, which is 9007199254740991 — the width at which a machine number stops being able to tell its neighbours apart — and results are held to the same ceiling, so an overflow is reported rather than answered approximately. Negative results carry a minus sign in front rather than being written in two's complement, and no fixed width is assumed: 1B is two digits here, not the low byte of anything. Lower case is accepted and answers are printed in upper case. Division by zero is refused. The page does arithmetic and conversion in three bases; it does not do bitwise operations, and there is no AND, OR, XOR or shift here.
Frequently asked questions
- What do the letters mean?
- They are digits. Base sixteen needs sixteen distinct digit shapes and there are only ten in the familiar set, so A through F stand for ten through fifteen — A is ten and F is fifteen. Nothing is encoded by the choice of letters; they are simply the next characters along in the alphabet, and any set of sixteen distinct symbols would do the same job. Uppercase and lowercase mean exactly the same digit here.
- Why does 1 + 1 not carry here when it does in binary?
- Because the base is different, so the column runs out at a different point. In base two there is no digit for two, so two ones carry immediately. In base sixteen there are digits all the way up to fifteen, so a column carries only when the sum passes F. Two plus two is four in every base; it is only the counting symbols that change.
- Does the capitalisation of my input matter?
- No. 2a3f and 2A3F are the same number and both are accepted, because the letters are digits and a digit is not case-sensitive. Answers are printed in capitals regardless. Both conventions are in daily use — CSS colour values are usually written in lower case while disassemblers and data sheets use capitals — so accepting both costs nothing and refusing either would be arbitrary.
- What is the largest number I can enter?
- 1FFFFFFFFFFFFF, which is fourteen hexadecimal digits and 9007199254740991 in decimal — a one followed by fifty-three ones in binary. Past that width a machine can no longer tell neighbouring whole numbers apart, so the arithmetic would silently stop being exact: the answer would look like a number without being one. Wider inputs are refused rather than truncated, and a result that overflows the same ceiling is refused too.
- Is this the same as a base converter?
- It is the arithmetic half of one. This page takes two numbers and an operation; the pages that convert a single value between bases are separate, and they are linked from this one. Combining everything into a single page with an input base and an output base dropdown would be a different design, and it would lose the ability to check the shape of what you type — a page that accepts any base cannot tell you that 2G is not a number in the base you picked.
- Why is there always a remainder row?
- Because the results panel is a fixed set of rows rather than a list that changes shape with the operation, and a row that came and went would be harder to read than one that stays put. Adding, subtracting and multiplying whole numbers cannot leave a remainder, so the row reads 0 for them, and that zero is the honest answer rather than a placeholder. For division it is what keeps a truncated quotient from looking like an exact answer.
References
- Hexadecimal — the base-sixteen system, the digits beyond nine, and the relationship between one hexadecimal digit and four binary digits — Wolfram MathWorld (United States)
- Number base — why a numeral's value depends on its position and on the base, and how the same quantity is written in different bases — Wolfram MathWorld (United States)
- IEEE 754 — the double-precision format these calculations are carried out in, and the 53-bit significand that fixes this page's input ceiling — IEEE Standards Association (United States)
- 教育部关于印发义务教育课程方案和课程标准(2022 年版)的通知——The fifth item in the annex list of this notice is the Mathematics Curriculum Standards for Compulsory Education (2022 edition); number systems and positional notation are part of the content where the mathematics and information technology curricula meet, and the wording of the standards and the grade-band breakdown are governed by that annex — 中华人民共和国教育部