Hex Calculator: Add, Subtract and Convert
Convert a number between hexadecimal, decimal and binary. Type the number, pick the base it is written in and press Convert. You get the value in hex, decimal, binary and octal at once. The calculator handles whole numbers of zero or more. A second mode adds, subtracts, multiplies and divides two hex numbers. Hex input may start with 0x and binary input with 0b, in upper or lower case. A character the base does not use, such as G in hex or 2 in binary, gets an error message instead of a result. Programmers meet hex in color codes, memory addresses and byte values.
How to use the Hex Calculator
- Enter your numbers in the Hex Calculator above.
- Press the Convert or Calculate button to see the result.
- To try other numbers, change any value and press the button again.
The hex conversion
Hex to decimal: Σ (digit × 16^position) · · · Hex digits: 0–9, A=10, B=11, C=12, D=13, E=14, F=15
Hex is base-16. Each hex digit represents 4 binary bits, making conversion to binary trivial. Hex is the standard "human-readable" representation of binary data in programming.
Worked example
Enter FF with Hex selected: 15×16 + 15 = 255 decimal, 11111111 binary and 377 octal. Enter 1A3F: 1×4,096 + 10×256 + 3×16 + 15 = 6,719 decimal, 1101000111111 binary and 15077 octal. For the color code #4A90E2, convert each pair on its own. 4A is 74, 90 is 144 and E2 is 226, so the color is RGB(74, 144, 226). In the second mode, 1A3F + FF gives 1B3E, which is 6,719 + 255 = 6,974 in decimal.
Frequently asked questions
Why use hex over binary?
A 32-bit number takes 32 binary digits but only 8 hex digits. Hex is much more compact and easier to read while preserving the bit-level structure (each hex digit maps to 4 specific bits).
What's the 0x prefix?
A common notation to indicate a hex value. 0xFF means hex FF = 255 decimal. Languages like C, Python and JavaScript all use 0x prefix. You can type it here too: 0xFF and FF give the same result.
How do hex colors work?
Six-digit hex colors represent RGB: first 2 digits red (00–FF), next 2 green, last 2 blue. #FF0000 = pure red, #00FF00 = pure green, #FFFFFF = white.
Can I add or subtract hex numbers here?
Yes. Switch to the second mode, type both numbers, pick the operation and press Calculate. For example, 1A + 0F gives 29 in hex, and the line below it shows 26 + 15 = 41 in decimal. The carries of an addition appear above the sum.
What happens with a negative result or a remainder?
A result below zero gets a minus sign, so 1A − FF shows −E5, which is 26 − 255 = −229 in decimal. Division gives a whole-number quotient and a remainder, so 1A ÷ 5 shows 5 and remainder 1.