Developer Tools
Binary arithmetic.
Add, subtract, multiply and divide binary numbers and see the working: carry and borrow rows, shift-and-add partial products, and long division with a remainder. Unsigned, exact for very large values, with an optional bit width and overflow flag. Runs in your browser.
Input
Result
Enter two binary numbers, then press Calculate.
How it works
- Add: work right to left. 0+0=0, 0+1=1, 1+1=10 (write 0, carry 1). The carry row shows the carry arriving at each column. Example: 1011 + 110 = 10001 (11 + 6 = 17).
- Subtract: 0−1 borrows from the next column (the column becomes 2, so 2−1=1). The borrow row shows the 1 that a column gives up because the column to its right had to borrow. Example: 1000 − 11 = 101 (8 − 3 = 5).
- Multiply: for every 1 bit in B, shift A left by that bit's position, then add the partial products. Example: 101 × 11 = 101 + 1010 = 1111 (5 × 3 = 15).
- Divide: long division. Bring down one bit of A at a time; if the running remainder is at least B, write 1 in the quotient and subtract B, otherwise write 0. Example: 1101 ÷ 10 = 110 remainder 1 (13 ÷ 2 = 6 r 1).
- Bit width and overflow: leave blank for unlimited size. With a width, both inputs must fit, and results wrap modulo 2width. Overflow means an add or multiply result needed more bits than the width; for subtract it means A < B (a borrow out of the top bit), so the result wraps.
- Unsigned only: this version treats every number as non-negative. For signed values see the two's complement calculator. Values use BigInt, so they are exact. Nothing is sent anywhere.
Sources: Wikipedia, Binary number: addition; multiplication; Wikipedia, Division algorithm: unsigned integer division with remainder. To convert text to bytes see the Binary Converter.