Binary Arithmetic Calculator
Calculate fixed-width binary addition, subtraction, multiplication, and division with carry, borrow, overflow, signed interpretation, unsigned interpretation, and hexadecimal display.
DIG-004 focuses on integer binary arithmetic used in digital systems. It does not model floating point, CPU instruction timing, pipeline behavior, IEEE-754, HDL generation, or physical ALU delays.
Engineering tool
Binary Arithmetic Calculator
Calculate fixed-width binary addition, subtraction, multiplication, division, carry, borrow, overflow, and signed or unsigned interpretation.
Enter a non-negative binary operand using only 0 and 1.
Enter the second binary operand. Division rejects zero.
Standard widths are 4, 8, 16, 32, and 64 bits. Custom width is limited.
Signed mode interprets fixed-width patterns as two's-complement values.
Result console
- Binary Result
- 1101
- Decimal Result
- 13
- Hex Result
- 0xD
- Full Binary Result
- 1101
- Bit Width
- 4bits
- Carry
- No
- Borrow
- No
- Unsigned Overflow
- No
- Signed Overflow
- No
Binary working
1010 + 0011 ---- 1101
Bit width range
| Mode | Minimum | Maximum | Values |
|---|---|---|---|
| Unsigned | 0 | 15 | 2^4 |
| Signed two's complement | -8 | 7 | 2^4 |
Formula reference
Binary Arithmetic Rules
The calculator uses fixed-width BigInt arithmetic and reports wrapped results and overflow flags separately.
Addition: Result = A + BSubtraction: Result = A - BMultiplication: Result = A × BDivision: Quotient = A / B, Remainder = A % BUnsigned range: 0 to 2^n - 1Signed range: -2^(n-1) to 2^(n-1)-1Variable definitions
- A, B
- binary operands
- n
- selected bit width
- Carry
- addition exceeds fixed-width unsigned maximum
- Borrow
- unsigned subtraction has A < B
- Overflow
- result cannot be represented in selected mode
- Two's complement
- standard signed integer representation
Worked Examples
Binary Addition
1010 + 0011 = 1101, decimal 13.
Carry Addition
1111 + 0001 in 4 bits wraps to 0000 with carry and unsigned overflow.
Binary Subtraction
1010 - 0011 = 0111, decimal 7.
Borrow Case
0000 - 0001 in 4-bit unsigned arithmetic wraps to 1111 with borrow.
Binary Multiplication
101 × 10 = 1010, decimal 10.
Binary Division
1100 / 0011 = 0100 with remainder 0.
8-bit Overflow
01111111 + 00000001 overflows signed 8-bit arithmetic.
Signed Addition
11111111 + 00000001 represents -1 + 1 = 0 in 8-bit signed mode.
Unsigned Maximum
An 8-bit unsigned value ranges from 0 to 255.
64-bit BigInt Case
A 64-bit all-ones value plus 1 wraps to zero with carry, without Number precision loss.
Engineering Notes
- Digital hardware uses fixed-width binary arithmetic.
- Overflow depends on the available bit width, not just the mathematical operation.
- The same binary pattern can represent different values depending on signed or unsigned interpretation.
- Unsigned range is 0 to 2^n - 1.
- Signed two's-complement range is -2^(n-1) to 2^(n-1)-1.
- JavaScript Number bitwise operators are 32-bit signed operations, so this calculator uses BigInt for fixed-width arithmetic.
- Carry and signed overflow are different flags and should not be treated as the same condition.
- This calculator does not model ALU propagation delay, CPU flags beyond the displayed arithmetic flags, or instruction-level behavior.
Common Mistakes
- Ignoring bit width.
- Confusing signed and unsigned interpretation.
- Assuming binary results always grow without wrapping.
- Ignoring overflow.
- Treating decimal conversion as the same problem as binary arithmetic.
- Forgetting subtraction borrow.
- Using JavaScript Number bitwise operators for 64-bit arithmetic.
- Assuming carry always means signed overflow.
Support reference
FAQ
What is binary arithmetic?
Binary arithmetic performs addition, subtraction, multiplication, and division using base-2 numbers made from 0 and 1.
How does binary addition work?
Binary addition follows the same column method as decimal addition, but each column has only two states. A carry occurs when a column exceeds 1.
What is a carry bit?
A carry bit is produced when an addition result exceeds the maximum value that can fit in the selected bit width.
What is borrow in binary subtraction?
Borrow occurs when the subtrahend is larger than the minuend for an unsigned fixed-width subtraction.
What is overflow?
Overflow means the mathematical result cannot be represented in the selected fixed bit width.
What is the difference between signed and unsigned binary?
Unsigned binary represents only non-negative values. Signed two's-complement binary uses the most significant bit as part of a negative-number encoding.
How many values can an n-bit number represent?
An n-bit pattern can represent 2^n distinct values, whether those values are interpreted as unsigned or signed.
Why does bit width matter?
Digital hardware uses fixed-width registers. Results that exceed the selected width wrap and may raise carry, borrow, or overflow flags.
How does binary multiplication work?
Binary multiplication produces partial products and adds shifted copies of the multiplicand when multiplier bits are 1.
Does this calculator simulate CPU arithmetic?
No. It models fixed-width integer arithmetic behavior and flags, but it does not simulate CPU instructions, pipeline timing, ALU delay, or assembly code.
Related Calculators
Logic Gate Truth Table Calculator
AvailableGenerate truth tables and compare standard logic gate behavior.
Open calculatorTwo's Complement Calculator
Coming_SoonPlanned calculator for signed two's-complement conversion and interpretation.
Binary Bitwise Calculator
Coming_SoonPlanned calculator for AND, OR, XOR, NOT, shifts, masks, and bit operations.
Gray Code Converter
Coming_SoonPlanned calculator for binary to Gray code conversion and reverse conversion.
Related Engineering Guides
Planned Guide
Binary Arithmetic Explained
Planned Guide
Carry and Overflow
Planned Guide
Signed vs Unsigned Numbers
Planned Guide
Bit Width in Digital Systems
Planned Guide
