🧮 Binary & Hex Arithmetic Calculator

Do arithmetic and bitwise operations on numbers entered in binary, octal, decimal or hex, and see the result in all four bases. This is a separate tool from the plain Number Base Converter, which only converts representation without doing math.

How the two numbers are combined

Each side is read in its own base, the operation runs on the integers, and the answer is printed in all four bases:

a = parseInt(A, baseA)      b = parseInt(B, baseB)

a + b      a - b      a × b      trunc(a / b)
a & b      a | b      a ^ b      a << b      a >> b

The defaults, 42 and 17 in decimal, add to 59 - shown as 111011 in binary, 73 in octal and 3B in hex. Those two share no set bits (101010 against 010001), so OR and XOR also return 59 while AND returns 0.

Bases, bit width and integer division

A negative result is shown as a minus sign in front of the magnitude: -5 is -101 in binary, not a two's complement pattern.

Frequently asked questions

What is 42 in binary and hex?

101010 and 2A. The binary digits are the 32, 8 and 2 columns; in hex, 2A is 2 lots of 16 plus 10.

Why does 42 AND 17 give zero?

AND keeps only the bits set in both numbers. 42 is 101010 and 17 is 010001, and no column holds a 1 in both, so every output bit is 0.

How do I add two hex numbers?

Set both base selectors to Hex and type the digits without a 0x prefix. FF plus 0F is 255 + 15 = 270, or 10E in hex.