calculator.onl
Categories50

Exact binary arithmetic calculator

Add, subtract, multiply or divide binary integers, with exact results, fixed-width wrapping and carry or overflow explanations.

A worked example

Add one, then two, to 1110. Which lamps stay on when the four-bit register overflows?

Binary result10000000Decimal result128Addition carry-out0Unsigned-word overflow0
Choose full exact signed integers, fixed-width unsigned words, or fixed-width two’s-complement words.

Word length from 1 through 128 bits; ignored in exact mode. Fixed-width results wrap modulo 2 raised to this width.

Operand A in binary. Exact mode permits an optional leading + or -. Word modes require an unsigned bit pattern; short inputs are zero-padded, so negative two’s-complement values need their full-width leading sign bit.

Select addition, A minus B, multiplication, or integer quotient A divided by B. Division also shows the exact signed remainder.

Operand B follows the same binary syntax as A. It must be nonzero for division.

Updates as you type

Use the stated ranges and input grammar. Enter finite values and decimal dots. Inactive fields are ignored.

YOUR RESULT

Binary result

10000000

Calculated from your inputs

Decimal result128
Division remainder · decimalNot applicable
Addition carry-out0
Subtraction borrow-outNot applicable
Signed-word overflow1
Unsigned-word overflow0
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

A fixed-width binary result can lose a leading carry, so read the width and any overflow indication alongside the output bits. Change “Binary operand A” from 01111111 to 11111111 and keep the other inputs from the worked example. The value for “Binary result” goes from 10000000 to 00000000. For a related calculation, try Bitwise calculator: AND, OR, XOR and shifts.

What to enter

InputWhat it meansExample value
Integer interpretationChoose full exact signed integers, fixed-width unsigned words, or fixed-width two’s-complement words.Fixed-width unsigned
Word width in bitsWord length from 1 through 128 bits; ignored in exact mode. Fixed-width results wrap modulo 2 raised to this width.8
Binary operand AOperand A in binary. Exact mode permits an optional leading + or -. Word modes require an unsigned bit pattern; short inputs are zero-padded, so negative two’s-complement values need their full-width leading sign bit.01111111
Arithmetic operationSelect addition, A minus B, multiplication, or integer quotient A divided by B. Division also shows the exact signed remainder.Add
Binary operand BOperand B follows the same binary syntax as A. It must be nonzero for division.1

How the calculation works

  1. Read the binary inputs as exact BigInt integers, interpreting a full-width leading 1 as negative in two’s-complement mode.
  2. Compute the exact arithmetic result and division remainder. For word modes, reduce the result modulo 2ʷ and apply the selected signed interpretation.
  3. Compare the mathematical signed and unsigned results with their respective width ranges; show bit-column carries or borrows, shifted partial products, or magnitude long division.
The formular = a ◦ b; word = r mod 2ʷ; a = bq + rem

A worked example

Our example: unsigned 8-bit 01111111 + 1 gives 10000000, decimal 128. Carry-out is 0; signed overflow is 1 because the same bit patterns represent 127 + 1, outside the signed range −128…127.

Example you can load

What to enter
Result for this example · Binary result10000000

This is a fixed example; changing the form above does not change these numbers.

Assumptions & limits

Exact mode accepts up to 512 binary digits per operand and retains the full result. Word modes accept widths 1–128 and inputs no longer than the width. No floating point, binary fractions, processor-specific flag emulation or bitwise operations. Division truncates toward zero; its remainder has the dividend’s sign. Signed and unsigned overflow reinterpret the same input bit patterns separately.

Frequently asked questions

How is carry different from signed overflow?

For 8 bits, 11111111 + 1 carries out and wraps to zero, while its signed interpretation is −1 + 1 = 0 without overflow. In contrast, 01111111 + 1 has signed overflow but no carry.

How do I enter a negative number?

In exact mode, prefix its magnitude with -. In two’s-complement mode, enter the full word: 11111111 means −1 at width 8. The short word 1 is padded with zeros and means +1.

What happens when division is not exact?

The quotient truncates toward zero and the remainder satisfies A = B × quotient + remainder. For example, −1101 ÷ 11 gives −100 with remainder −1 in decimal.