Perform arithmetic and bitwise operations on binary numbers. Results are shown in binary, decimal, hexadecimal, and octal.
| Base | Result |
|---|---|
| Binary (2) | 10000 |
| Decimal (10) | 16 |
| Hex (16) | 10 |
| Octal (8) | 20 |
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
NOR of 1010 and 0110 is 0001 in four bits, 11110001 in eight bits and sixty leading ones followed by 0001 in 64 bits. The inputs never changed; only the width did. That is the surprise hiding in every inverted-bit operation, and it is why this page has a Bit width list that appears whenever you pick AND, OR, XOR, NOR or XNOR. Arithmetic needs no such setting, so the page treats the two families differently, and the sections below show how.
Start with the values the page loads: A = 1010 (decimal 10) and B = 0110 (decimal 6). Add gives 10 + 6 = 16, shown as 10000 with hex 10 and octal 20. Multiply gives 60, shown as 111100 (hex 3C, octal 74). Divide gives the integer quotient 1 and the note "Integer quotient; remainder 100 (binary)", because 10 = 1 x 6 + 4 and 4 is 100 in binary.
Subtract is where the sign shows up. 1010 - 0110 is 100 (decimal 4), but use 1010 - 1111 instead and the page prints -101 (decimal -5), with a note that in 4-bit two's complement the same value would be 1011. The Step-by-step panel lines up the absolute values and puts a minus sign in front of the answer row. The two's complement figure is simply 2 to the power of the width, plus the negative result: 16 - 5 = 11, which is 1011. Larger magnitudes move the note to 8, 16 or 32 bits, the first width with room for a sign bit.
The five logic operations compare bits column by column and never carry. With Auto width the page pads to the longer input, here four bits. AND = 0010 (2), OR = 1110 (14), XOR = 1100 (12). NOR is NOT(A OR B), so it inverts the OR result inside the chosen width: 1110 becomes 0001 (1). XNOR inverts XOR: 1100 becomes 0011 (3). Pick 8-bit and the same NOR reads 11110001, which is 241 in decimal, hex F1, because the four extra leading zeros of OR flip to ones.
A shortcut check for any width w: NOR(A, B) = 2^w - 1 - (A OR B). At four bits that is 15 - 14 = 1; at eight bits it is 255 - 14 = 241.
Bitwise results are labelled "unsigned" under the big binary figure because no sign bit is applied. If either input needs more bits than the width you picked (11111 needs five bits, so 4-bit fails), the page shows an error and asks for a wider width or Auto. Values are held as arbitrary-size integers, so a 33-bit input is exact rather than clipped, and each box accepts up to 256 digits.
No. Both boxes accept only the digits 0 and 1, so other keys are ignored. The page converts binary in, decimal, hex and octal out. For decimal to binary, divide by 2 repeatedly and read the remainders from last to first: 25 gives 11001.
No, it is a sign plus magnitude, such as -101 for -5. The note under the result gives the two's complement pattern for the smallest standard width that can hold it, which is 1011 at four bits. Use that pattern if you are writing it into a register or an exercise.
The width of the register or data type you are modeling: 8 for a byte, 32 or 64 for common integer sizes. Auto only matches the longest number you typed, which is right for a textbook exercise written at a fixed number of bits and wrong for anything else.
The quotient is cut off toward zero and the remainder appears in a note below the answer in binary. For 1010 divided by 0110 the quotient is 1 and the note says remainder 100. Fractions are never produced.
Each box takes up to 256 digits, and the arithmetic is exact at that size. Bitwise results are padded to the chosen width, so a 256-bit input needs Auto or a width that covers it, and the 64-bit option rejects anything wider.