How this calculator works
Binary arithmetic uses the same column rules as decimal arithmetic, but every column carries at two rather than ten. The two operands are read in the base you choose and stored in a fixed width of up to 32 bits. Addition and multiplication are rejected when the exact answer needs more bits, rather than silently wrapping. Subtraction may go below zero: the difference is then stored in two's complement, so the leading 1 has a negative value. The unsigned decimal output reads the stored bits as a plain count; the signed output reads the leading bit as a sign. Division gives a quotient and a remainder, both in binary and in decimal.
Formula
Sum = a + b. Difference = a - b. Product = a × b. Quotient = floor(a / b), remainder = a - b × floor(a / b). In n bits the stored value of a negative difference d is d + 2ⁿ, and the signed reading is stored - 2ⁿ when the leading bit is 1.
Worked example
In 8 bits, 1101 (13) plus 0101 (5) is 10010 (18). Subtracting 1101 (13) from 0101 (5) gives -8, stored as 11111000, which reads as 248 unsigned and -8 signed. Dividing 1101 (13) by 0101 (5) gives quotient 10 (2) and remainder 11 (3).
Advertisement
Frequently asked questions
Why does the signed result disagree with the unsigned result?
Both read the same stored bits. The unsigned reading treats every bit as a positive place value. The signed reading treats the leading bit as 2ⁿ⁻¹ below zero, which is the two's complement convention used by most computers.
Why is a large sum rejected instead of wrapped?
Wrapping hides a mistake. The calculator reports that the answer needs more bits, so you can widen the bit width or reduce the operands. Subtraction is the exception: a negative answer is stored as two's complement because that has a defined meaning.
What does the remainder mean after division?
The quotient is the whole number of times the divisor fits into the dividend. The remainder is what is left over. For 13 divided by 5, the quotient is 2 and the remainder is 3.
Can I enter decimal numbers directly?
Yes. Set the input base to decimal and type ordinary whole numbers. Values must be non-negative and must fit in the chosen bit width.