UTILS.
100% in-browser
0b

Binary & Hex Calculator

Add, subtract, multiply, divide or bit-shift and combine numbers in binary, octal, decimal and hex with exact BigInt math.

About this tool

This calculator works two operands in any base you like — binary, octal, decimal or hexadecimal — and shows the result in all four bases at once. Everything runs in your browser with no network calls, no rounding libraries and no eval.

Each operand is parsed with JavaScript BigInt (via the 0b, 0o and 0x prefixes, or plain decimal), so there is no floating-point error and no 32/64-bit overflow — numbers can be arbitrarily large. Arithmetic (add, subtract, multiply, divide) and bitwise operations (AND, OR, XOR, left shift, right shift) are all computed on BigInt values. Division is integer division and also reports the remainder (a mod b).

Enter operand A and its base, choose an operation, enter operand B and its base, and the result appears instantly in decimal (primary), binary, octal and hexadecimal. Divide-by-zero and invalid digits for the chosen base are caught and shown as an input error.

Frequently asked questions

How are the numbers calculated?
Both operands are parsed into BigInt and all math is done with BigInt, so results are exact for arbitrarily large integers with no floating-point rounding and no eval.
What does division return?
Division is integer division: it returns the quotient a / b truncated toward zero, plus the remainder a mod b shown as a separate tile. Dividing by zero is rejected as invalid input.
Can I mix bases, like AND a hex value with a binary value?
Yes. Operand A and operand B each have their own base selector, so you can combine a hex number with a binary or decimal number; the answer is still shown in all four bases.
How are negative numbers and shifts handled?
A leading minus sign is accepted for any base. Left and right shifts use the second operand as the shift count (0 and up); very large or negative shift counts are treated as invalid input.

More tools