Advanced calculator for binary arithmetic, bitwise operations, and number system conversions. Perform calculations with binary, decimal, hexadecimal, and octal numbers.
Binary Arithmetic: Perform addition, subtraction, multiplication, and division with binary numbers.
Binary is a base-2 number system that uses only two digits: 0 and 1. Each digit in a binary number is called a bit (binary digit). Binary is the fundamental language of computers and digital systems.
Binary Place Values:
In binary, each position represents a power of 2:
... 2³ 2² 2¹ 2⁰ . 2⁻¹ 2⁻² ...
So the binary number 1011 represents: (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11 (decimal)
| Binary Addition | ||
|---|---|---|
| A | B | A + B (Carry, Sum) |
| 0 | 0 | 0, 0 |
| 0 | 1 | 0, 1 |
| 1 | 0 | 0, 1 |
| 1 | 1 | 1, 0 |
| 1 | 1 (with carry 1) | 1, 1 |
| Binary Subtraction | ||
|---|---|---|
| A | B | A - B (Borrow, Difference) |
| 0 | 0 | 0, 0 |
| 0 | 1 | 1, 1 (with borrow) |
| 1 | 0 | 0, 1 |
| 1 | 1 | 0, 0 |
AND (&): Returns 1 only if both bits are 1. Used for masking (extracting specific bits).
1010 & 1100 = 1000 (bits 1 and 3 are 1 in both)
OR (|): Returns 1 if at least one bit is 1. Used for setting bits.
1010 | 1100 = 1110 (bits 1, 2, and 3 are 1 in at least one)
XOR (^): Returns 1 only if bits are different. Used for toggling bits.
1010 ^ 1100 = 0110 (bits 2 and 3 are different)
NOT (~): Inverts all bits (0 becomes 1, 1 becomes 0). Also called one's complement.
~1010 = 0101 (in an 8-bit system: ~00001010 = 11110101)
Left Shift (<<): Shifts bits to the left, filling with 0s. Equivalent to multiplying by 2ⁿ.
1010 << 2 = 101000 (shift left by 2 positions)
Right Shift (>>): Shifts bits to the right. For unsigned numbers, fills with 0s. Equivalent to dividing by 2ⁿ (integer division).
1010 >> 2 = 0010 (shift right by 2 positions)
Two's complement is a mathematical operation on binary numbers, and is the most common method of representing signed integers in computers.
To find the two's complement of a negative number:
Example: -5 in 8-bit two's complement:
1. +5 in binary: 00000101
2. Invert bits: 11111010
3. Add 1: 11111011 (this is -5 in two's complement)
| Decimal | Binary | Hexadecimal | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 8 | 10 |
| 9 | 1001 | 9 | 11 |
| 10 | 1010 | A | 12 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
| 255 | 11111111 | FF | 377 |
Calculator Features:
1010 + 1101
= 10111
1111 - 1010
= 0101
110 × 101
= 11110
1010 & 1100
= 1000
1010 | 1100
= 1110
1010 ^ 1100
= 0110