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

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 with parseInt and writes results with Number.toString, always 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, not a two's-complement bit pattern: 5 − 8 in hex is -3, not FFFFFFFD. Division keeps only the whole part, so 7 ÷ 2 is 3. AND, OR, XOR and NOT run on 32-bit values: NOT F0 returns FFFFFF0F (4294967055 in decimal), but FFFFFFFF OR 0 displays -1 because the 32-bit pattern is read as signed. For NOT, only the highlighted result box fills in; the four-base table beneath it stays blank.

Size limit. Past 2^53, about 9 quadrillion, ordinary numbers lose digits. Sixteen F's in a row convert to 10000000000000000, which is wrong. For values that large, use the Big Number calculator and keep this page for byte, word and colour-sized work.

Writing a negative number as a byte takes a small workaround. To get -3 as 8 bits, subtract in hex: 100 − 3 = FD. The bitwise route gives the same result: NOT 2 returns FFFFFFFD, and ANDing that with FF leaves 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. Read the large result in your chosen base, then the four-base table below it. 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?

Because AND, OR, XOR and NOT are carried out on 32 bits here. Anything above 4,294,967,295 (FFFFFFFF) is cut down, and a result with the top bit set can appear negative.

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.