Hex Calculator

Convert numbers between hexadecimal, decimal, binary, and octal. Perform arithmetic and bitwise operations (AND, OR, XOR, NOT) in any number base.

Mode

Decimal value: 255

Exact for any length (up to 200 characters). Negative values are shown with a minus sign; use the Arithmetic tab for fixed-width two's complement.

Results

BasePrefixValue
Binary0b11111111
Octal0o377
Decimal—255
Hexadecimal0xFF
HexDecBinOct
0000000
1100011
2200102
3300113
4401004
5501015
6601106
7701117
88100010
99100111
A10101012
B11101113
C12110014
D13110115
E14111016
F15111117

Priya is reading a memory dump where one byte shows 8C, and the data sheet she is checking it against lists the value as 140. A few keystrokes settle it: 8C in hex is 140 in decimal, 10001100 in binary and 214 in octal. The page also does arithmetic and bitwise operations directly in the base you pick, so FF + 1A can stay in hex instead of taking a detour through decimal.

Reading and writing values in four bases

Typical case: convert hex 8C. Each digit is worth a power of 16, and C stands for 12, so 8 × 16 + 12 = 140. In binary, 8 is 1000 and C is 1100, so the byte is 10001100. In octal, 140 = 2 × 64 + 1 × 8 + 4, which is 214. Under the hood the page reads your text as an exact big integer and writes results in capital letters.

Arithmetic works the same way. FF + 1A is 255 + 26 = 281, which is 119 in hex, 100011001 in binary and 431 in octal. Both inputs are turned into ordinary numbers, the operation is done, and the answer is shown in all four bases at once.

Edge cases. Subtract past zero and you get a signed result with a minus sign, plus a two's-complement column for the chosen width: 5 − 8 in hex is -3, and its 32-bit two's complement is FFFFFFFD. Division keeps only the whole part, truncated toward zero, so 7 ÷ 2 is 3 and -8 ÷ 3 is -2. The Arithmetic tab has a Bit width selector (8, 16, 32 or 64, starting at 32). AND, OR, XOR and NOT work on the two's-complement pattern of that width and show the result as an unsigned pattern, with the signed reading underneath. NOT F0 at 32 bits returns FFFFFF0F (4,294,967,055 in decimal, signed -241), and the four-base table fills in as for any other operation. FFFFFFFF OR 0 returns FFFFFFFF, whose signed reading is -1.

Size. Arithmetic is exact at any size, because the page uses big integers rather than ordinary floating-point numbers. Sixteen F's in a row convert to 18446744073709551615, and FFFFFFFFFFFFFFFF + 1 at 64 bits gives 10000000000000000 with a note that it wraps to 0 in the two's-complement column. Inputs must fit the chosen width, signed or unsigned: at 32 bits that means -2,147,483,648 to 4,294,967,295, and a larger value gets a message asking for a wider width. Each number is capped at 200 characters. For decimal-only work on very long integers, the Big Number calculator is simpler.

Writing a negative number as a byte is direct. Choose the 8-bit width and compute 0 − 3 in hex: the two's-complement column shows FD. The bitwise route agrees, because NOT 2 at 8 bits is also FD.

How to Use This Calculator

  1. Choose the Base Converter tab or the Arithmetic tab.
  2. In the converter, set the Input Base, then type the value. The box rejects digits that do not belong to the base, so a 2 is ignored in binary. Changing the base empties the box.
  3. Read the table of binary, octal, decimal and hexadecimal results. The prefixes 0b, 0o and 0x appear only in the Prefix column, and your input row is shaded.
  4. In Arithmetic, pick the Number Base, type A, choose an operation (+, -, ×, ÷, AND, OR, XOR or NOT) and type B. NOT hides the B box. Changing the base clears both numbers.
  5. Choose the Bit width (8, 16, 32 or 64) that matches your data. Read the large result in your chosen base, then the four-base table below it, which has a two's-complement column for that width. A 0 to F reference table sits at the bottom.

Frequently Asked Questions

Can I enter a decimal point or a fraction?

No. The boxes accept only digits for the chosen base and an optional leading minus sign, so values such as 3.7 or 0.1 cannot be typed. Everything is treated as a whole number.

Do I type the 0x prefix?

No, the letter x is rejected by the input filter. Type only the digits, for example FF, and read the 0x prefix in the results table.

Does the case of the letters matter?

Not when typing. Lower-case a to f is accepted and results always come back in capitals.

Why does my bitwise result not match my 64-bit program?

Check the Bit width selector, which starts at 32. Set it to 64 for 64-bit data. Values are never cut down: an input that does not fit the width gets a message, and the signed reading of a pattern with the top bit set is shown separately from the unsigned pattern.

How do I convert a colour like #FF8C00?

Split it into FF, 8C and 00 and convert each pair, which gives 255, 140 and 0. Pasting FF8C00 as one value gives 16,747,520, which is correct as a single number but not as red, green and blue.