Skip to content
Math

Binary Calculator

Perform arithmetic and bitwise operations on two binary numbers with a selectable bit-width (4, 8, 16, or 32 bits). Every result is shown in binary, decimal, octal, and hexadecimal, including the signed two's-complement interpretation. A built-in base converter translates any single number between binary, decimal, octal, and hex.

Your details

Limit the result to this many bits, matching common integer types (byte = 8, short = 16, int = 32). Choose "Unlimited" for arbitrary-precision arithmetic.
A binary value using only the digits 0 and 1.
Use only digits valid for the chosen base: 0-1 for binary, 0-7 for octal, 0-9 for decimal, 0-9 and a-f for hex.
Result (binary)
00010000
Signed interpretation16 (positive, same as unsigned)
Result (decimal, unsigned)16
Result (octal)20
Result (hexadecimal)10
Remainder (binary)-
Remainder (decimal)-
Converter: decimal-
Converter: binary-
Converter: octal-
Converter: hexadecimal-

Result: 00010000 in binary (8-bit).

  • 1010 + 110 = 00010000 in binary (8-bit).
  • That is 16 in decimal, 020 in octal, and 0x10 in hex.
  • Each hex digit packs exactly four binary bits, so one byte (8 bits) maps neatly to two hex characters.

Next stepUse the base converter below to translate any single value between binary, octal, decimal, and hex.

Formula

r=maskn-bit(A2    B2),shown in base 2, 8, 10, 16r = \text{mask}_{n\text{-bit}}(A_2 \;\circ\; B_2),\quad \text{shown in base 2, 8, 10, 16}

Worked example

Add binary 1010 and 110 in 8-bit mode. Parse: 1010 = 10, 110 = 6. Then 10 + 6 = 16. Masked to 8 bits: 16 fits (max 255), so the result is 00010000 in binary, 20 in octal, and 0x10 in hex. Subtracting: 1010 - 0011 means 10 - 3 = 7, or 00000111. Bitwise NOT of 00001010 in 8-bit flips all bits to 11110101, which is 245 unsigned or -11 as a signed byte.

How binary arithmetic works

Binary numbers add, subtract, multiply, and divide using the same place-value rules as decimal, except every place is a power of two instead of ten. When two 1 bits add together the column overflows and carries a 1 to the next position, just as 9 + 1 carries in decimal. This calculator converts each binary operand to its decimal value, applies the operation, then converts the answer back. The result is then masked to the bit-width you selected (4, 8, 16, or 32 bits), so any overflow wraps exactly as it would in a real CPU register or a fixed-width variable in C or Java.

Bit-width modes and signed vs. unsigned values

Choosing a bit-width matters because real hardware stores integers in fixed-size registers. An 8-bit byte holds 0 to 255 unsigned, or -128 to 127 if treated as a signed two's-complement integer. Overflow wraps: adding 1 to the maximum 8-bit value 11111111 rolls back to 00000000. This calculator always shows the unsigned result (the raw bit pattern) plus the signed interpretation in parentheses, so you can see both views at once. The "Unlimited" mode skips masking and uses JavaScript's safe integer range, useful for exploring large numbers without wrap-around.

Bitwise operations and shifts

AND keeps a bit only where both numbers have a 1. OR keeps a bit where either number has a 1. XOR keeps a bit where exactly one number has a 1. NOT (a unary operation) flips every bit. A left shift moves bits toward the high end, effectively multiplying by 2 for each position, while a right shift divides by 2. These operations are fundamental in graphics (color masking), networking (subnet masks), and systems programming (flag manipulation). The result is always masked to the selected bit-width, so NOT of 0000 1010 in 8-bit correctly gives 1111 0101, not a 32-bit pattern.

Reading results in four bases

Every answer is shown in binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Binary shows the literal bit pattern. Octal groups bits in threes and was widely used in Unix file permissions (e.g., chmod 755). Hexadecimal groups bits in fours and is the standard compact notation for memory addresses, color codes (CSS), and byte values in debugging. Decimal is the everyday number for human comparison. Seeing all four simultaneously makes it easy to verify your work across programming and hardware contexts.

Base converter: binary, octal, decimal, hex

The base converter below the main calculator translates a single number between all four bases. Enter any value in the input box, select its base (binary, octal, decimal, or hex), and the other three representations update immediately. This is useful for quickly converting a hex memory address to binary, an octal Unix permission to decimal, or any other single-value translation without needing to set up an arithmetic operation.

Common values in four bases

DecimalBinaryOctalHexadecimal
0000
1111
21022
31133
410044
711177
81000108
10101012A
15111117F
16100002010
20101002414
321000004020
64100000010040
12711111111777F
1281000000020080
25511111111377FF
256100000000400100

Decimal, binary, octal, and hexadecimal representations for values 0 to 20 and selected powers of two.

Frequently asked questions

How do I add two binary numbers with this calculator?

Type the first binary number in the "Binary number A" box, keep the operation set to Add (+), and type the second number in the "Binary number B" box. The result appears instantly in binary, decimal, octal, and hex. For example, 1010 + 110 in 8-bit mode gives 00010000, which is 16 in decimal and 0x10 in hex.

What does the bit-width setting do?

The bit-width limits the result to a fixed number of bits (4, 8, 16, or 32), matching real CPU register sizes. When a result exceeds the maximum for that width, it wraps around (overflow). For example, adding 1 to the 8-bit maximum 11111111 (255) wraps to 00000000 (0). "Unlimited" skips masking so you can work with any integer size. The signed interpretation column always shows how the bit pattern reads as a two's-complement signed integer.

What is the difference between AND, OR, and XOR?

All three compare bits in the same position across both numbers. AND outputs 1 only where both inputs are 1 (useful for masking bits off). OR outputs 1 where at least one input is 1 (useful for setting bits). XOR outputs 1 where exactly one input is 1 (useful for toggling bits or detecting differences). NOT is a unary operation that flips every bit of operand A, ignoring operand B entirely.

What is the signed interpretation shown next to the result?

In two's-complement notation, the most significant bit of a fixed-width integer signals the sign. In 8-bit mode, bit patterns from 00000000 to 01111111 represent 0 to 127 (positive); 10000000 to 11111111 represent -128 to -1. The calculator always shows the raw unsigned value plus the signed reading so you can understand how the same bit pattern is interpreted in signed vs. unsigned contexts, as seen in C (int vs. unsigned int) or Java (byte vs. integer).

What is the difference between binary, octal, decimal, and hexadecimal?

These are the same numbers written with different bases. Binary (base 2) uses digits 0-1 and directly represents bit patterns. Octal (base 8) uses digits 0-7, grouping bits in threes, and appears in Unix file permissions. Decimal (base 10) is the familiar everyday number system. Hexadecimal (base 16) uses digits 0-9 and A-F, grouping bits in fours, and is standard for memory addresses, color codes, and debugging. Only the notation changes, not the underlying quantity.

Does the calculator handle division with a remainder?

Yes. Choose the Divide (/) operation and the calculator shows the integer quotient in the result row. A separate row shows the remainder in both binary and decimal. For example, dividing 1010 (10) by 11 (3) gives quotient 11 (3) with remainder 1. Use the Modulo option instead if you only need the remainder.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…