gizmobench
BrowseDaily

Binary Calculator

Enter binary integers and choose arithmetic, a bitwise operation or a shift. The result includes decimal, hex and octal representations, with carries, borrows or partial products where applicable. Choose a fixed width for signed two's-complement interpretation, NOT or NEG; overflow keeps the exact answer beside the wrapped bits.

AddUnsignedWidth auto
carry     1  1  1

             1  0  1   =  5
+               1  1   =  3
        ------------
          1  0  0  0   =  8

decimal  8       hex  0x8       octal  010
overflow  none    bits used  4
Result
1000
Decimal
8
Bits used
4
Overflow
None
First number
Second number
Math
Bits
Reading
Width

101 + 11 = 1000, which is 8 in decimal, written in 4 bits. Unsigned with no fixed width, so the answer is a plain binary number and nothing was dropped.

Column addition from the least significant bit, with the carry out of each column drawn over the column it lands in. No fixed width: the operands are whole binary numbers of any length, and nothing wraps.

Each box takes binary digits only, and spaces, underscores and an 0b prefix are read rather than refused, so 1010 1010 and 0b10101010 are the same number. With the width on Auto there is no register to fall out of: the numbers are whole integers of any length up to 4096 digits a box, and a subtraction that goes below zero comes back with a minus sign. Pick a width and the same bits become a register: Unsigned reads them as a magnitude, Signed reads the top bit as a sign, and an answer that does not fit is shown wrapped with the overflow flag raised and the exact answer printed beside it. For the two shifts the second box holds the number of places, written in binary like everything else. The column grid is drawn whenever every row fits 24 columns and no minus sign is involved; past that the same rows are printed without the grid. Your entry is kept in this browser so the page opens where you left it.

  • 101 + 11unsigned
    1000, that is 8
  • 11111111 at 8-bit signedtwo's complement
    11111111, that is -1
  • 1010 divided by 0integer divide
    Refused: Division by zero has no answer. Change the second number to something other than 0.
Binary fractions and IPv4 conversions

Binary fractions and IPv4

These are positional values, with a minus sign for negative values. They are separate from the integer register above and do not interpret a fixed-point encoding. Each input allows 256 characters. Parentheses in output mark a repeating cycle; an ellipsis marks a 128-digit preview. The reduced fraction always remains exact.

Exact reduced fraction
7/4
Binary exact
1.11
Decimal exact
1.75

These conversion fields are kept only while this view is open. They do not write over the integer calculator's remembered inputs.

Integer accuracy. Exact integer arithmetic on arbitrary-precision integers, so a long operand is never truncated or turned into a floating-point number. Unsigned is the default and a negative result is labelled as such. Fixed-width mode reads the same bits as two's complement and raises an overflow flag instead of wrapping quietly. Division is integer division and the remainder is shown beside it. The exact answer, the answer the width holds and the overflow flag are kept apart on the panel above, so a wrapped result can never be read as an exact one.

Common questions

How do you add two binary numbers by hand?
Line the two numbers up on the right and work from the last column to the first, exactly as in decimal, except that the only sum that carries is 1 + 1. Take 101 + 11. The last column is 1 + 1, which is 0 carry 1. The next is 0 + 1 plus that carry, which is 0 carry 1 again. The next is 1 + 0 plus the carry, 0 carry 1, and that final carry becomes the leading digit: 1000, which is 8. This page draws that carry row above the sum, so the three carries are on screen rather than in your head.
What does 11111111 mean in binary?
It depends on how wide the number is and whether it is signed, which is why the width and the mode are settings here rather than assumptions. Read as an unsigned byte, 11111111 is 255. Read as a signed 8-bit value in two's complement, the top bit is the sign, so the same eight bits are -1. Set the width to 8 and switch between Unsigned and Signed to see both readings of one pattern. The two corners work the same way: 01111111 is 127 in both readings, and 10000000 is 128 unsigned and -128 signed.
What happens when the answer does not fit the bit width?
The bits wrap the way a register wraps, and the page says so rather than letting you read a wrong number as a right one. At four unsigned bits, 1111 + 1 is 0000, because the carry out of the top column has nowhere to go. The Overflow cell turns to Yes, the panel prints the exact answer 10000 beside the wrapped one, and the note says it kept the low 4 bits. With the width set to auto there is no register to overflow, so the same sum is simply 10000.
How does binary division work on this page?
It is integer division, truncated toward zero, and the remainder comes back with the quotient instead of being thrown away. 1010 divided by 11 is 10 divided by 3, so the quotient is 11, which is 3, and the remainder is 1. Both lines are printed under the rule, and the identity that checks them is the one you would use on paper: quotient times divisor plus remainder equals the number you started with. Dividing by zero is refused with a message that names the box to change, because no answer exists to show there.
What do AND, OR, XOR and NOT do to a binary number?
They work one column at a time with no carries at all. AND puts a 1 where both numbers have a 1, OR where either does, and XOR where exactly one does, so 1100 XOR 1010 is 110, which is 6. NOT flips every bit, which is why it needs a fixed width: with no width there is no last bit to flip. Choosing NOT while the width is on Auto moves the width to 8 bits rather than leaving you on a refusal, and setting the width back to Auto then says plainly what is missing. At 8 bits, NOT 00001111 is 11110000, which is 240 unsigned. The two shifts are here too, and the second box holds the number of places written in binary like everything else, so 11 there means three places and 101 shifted left gives 101000, which is 40.
How large a binary number can it handle?
Up to 4,096 binary digits in each box, which is far past any register you are likely to be checking, and the arithmetic stays exact the whole way. Nothing is converted to a floating-point number at any point, so 2^53 + 1 comes back as 9007199254740993 rather than the 9007199254740992 a calculator built on doubles returns. Paste something longer than the limit and the page says how long it was and what the limit is instead of quietly cutting it. Fixed widths go up to 64 bits, and the auto setting has no width at all.
Is a negative answer wrapped or signed?
With no fixed width it is signed: 11 minus 101 is 3 minus 5, so the answer is -10, which is -2, written with a minus sign because there are no bits to wrap into. With a fixed width it wraps, because that is what a register of that size does: the same subtraction at four unsigned bits is 1110, which is 14, and the overflow flag is raised with the exact answer, -10 in binary, printed beside it. Both behaviours are on screen with a label, so neither one can be mistaken for the other.
How do I calculate the two's complement of a binary number?
Choose NEG and a fixed width. It flips the bits and adds one, keeping the chosen width. In signed 8-bit mode, 00000101 represents 5 and NEG returns 11111011, or -5. Negating 10000000 would require +128, outside the signed byte range, so the wrapped result remains 10000000 and Overflow says Yes. Zero remains zero. In unsigned mode, a nonzero negative result wraps and is flagged.
Is NOT the same as two's complement?
NOT flips every bit and gives the one's complement. NEG flips every bit and adds one, giving the two's-complement negative at the selected width. For 00000101 at eight bits, NOT gives 11111010 and NEG gives 11111011. The displayed decimal value also depends on the Signed or Unsigned reading.
How do I read a signed binary value as decimal?
Set a fixed width and Signed, choose addition, and put zero in the second box. For an 8-bit reading, 11111111 gives decimal -1. Enter the complete bit pattern: shorter inputs are padded with leading zeros to the chosen width, so 1111 at eight bits is +15, while 1111 at four signed bits is -1.
Can I type decimal, hex, octal or fractional input?
The integer operand boxes accept whole binary integers and reject a binary point rather than removing it. Open Binary fractions and IPv4 conversions for positional binary fraction arithmetic, decimal or rational fractions to binary, and binary fractions to decimal. These modes keep exact reduced fractions. They do not interpret fixed-point register encodings, IEEE 754 arithmetic, BCD or Gray code.
Does division print every long-division subtraction?
It prints the dividend, divisor, quotient and remainder, but not the successive partial remainders of a manual long-division trace. Addition and subtraction show carry or borrow columns when the diagram fits; multiplication shows partial products when their count and signs allow it.
Is this a Boolean algebra or probability calculator?
This page performs numeric arithmetic and bitwise operations on integer bits. It does not simplify symbolic Boolean expressions, calculate a binomial distribution or take a base-2 logarithm. Those tasks use different inputs and outputs.
Can I use the binary calculator on a phone or desktop?
Open this page in a browser and enter your bits. Operand fields allow a minus sign for Auto width, spaces, underscores and a 0b prefix. Choosing a fixed width requires an unsigned bit pattern without a minus sign. Calculations stay in the browser.
How do I calculate with binary fractions?
Open Binary fractions and IPv4 conversions, then choose Binary fraction arithmetic. Enter values such as 1.01 and 0.1 and select Add, Subtract, Multiply or Divide. Their sum is 1.11 in binary, 1.75 in decimal, and the exact fraction 7/4. Choose Decimal or fraction to binary for a value such as 0.1 or 1/3. Parentheses identify a complete repeating cycle; an ellipsis identifies a 128-digit preview, with the exact fraction kept beside it.
Can I convert an IP address to binary and back?
In Binary fractions and IPv4 conversions, choose IPv4 to binary or Binary to IPv4. The address 192.168.1.5 becomes 11000000 10101000 00000001 00000101. All leading zero bits within each byte are kept. Reverse input accepts exactly 32 bits, or four groups of eight separated by spaces or dots. Decimal octets are read as decimal even with leading zeros. This converts IPv4 addresses and does not calculate subnets or perform an IP lookup.
Which accuracy note applies to fraction calculations?
The integer accuracy note describes the integer register above. The separate fraction section uses exact reduced numerator and denominator arithmetic, including division with a nonzero divisor. Finite expansions and fully detected repeating cycles are exact; a long expansion is labelled preview and retains its exact fraction.

Exact integer arithmetic on arbitrary-precision integers, so a long operand is never truncated or turned into a floating-point number. Unsigned is the default and a negative result is labelled as such. Fixed-width mode reads the same bits as two's complement and raises an overflow flag instead of wrapping quietly. Division is integer division and the remainder is shown beside it.