Perform binary arithmetic and convert between binary and decimal number systems.
Binary value:
10101010 + 11001100
= 0101110110
Decimal value:
170 + 204
= 374
Decimal value: 170
Binary value: 10101010
Binary is a base-2 numeral system that uses only two symbols: 0 (zero) and 1 (one). Each digit is called a bit (binary digit). Unlike the decimal system (base-10) which uses ten digits, the binary system is positional, meaning each digit's value depends on its position from right to left, with each position representing a power of 2.
Binary is the fundamental language of digital electronics and computing. All modern computers store and process data in binary form because electrical circuits naturally represent two states: on (1) and off (0).
| Bit Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Power of 2 | 2⁷ = 128 | 2⁶ = 64 | 2⁵ = 32 | 2⁴ = 16 | 2³ = 8 | 2² = 4 | 2¹ = 2 | 2⁰ = 1 |
| Example: 10101010 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
10101010₂ = 128 + 32 + 8 + 2 = 170₁₀
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| A | B | Difference | Borrow |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| A | B | Product |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Binary multiplication is similar to decimal long multiplication, but only uses 0 and 1.
Binary division follows the same long division structure as decimal division. The divisor is subtracted from the dividend repeatedly using binary subtraction, and the quotient is built bit by bit. Division by zero is undefined.
To convert binary to decimal: start from the rightmost bit. Multiply each bit by 2 raised to its position index (starting at 0). Sum all the results.
Example: 1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11₁₀
To convert decimal to binary: repeatedly divide the decimal number by 2 and record the remainder (0 or 1). Continue until the quotient becomes 0. Read the remainders from last to first — this is the binary value.
Example: 13 ÷ 2 = 6 rem 1
6 ÷ 2 = 3 rem 0
3 ÷ 2 = 1 rem 1
1 ÷ 2 = 0 rem 1
Result (read bottom-up): 1101₂
| Unit | Size | Description |
|---|---|---|
| Bit | 1 binary digit | Smallest unit of digital information |
| Nibble | 4 bits | Half a byte; represents one hexadecimal digit |
| Byte | 8 bits | Standard unit for computer storage |
| Kilobyte (KB) | 1,024 bytes | 2¹⁰ bytes |
| Megabyte (MB) | 1,048,576 bytes | 2²⁰ bytes |
| Gigabyte (GB) | 1,073,741,824 bytes | 2³⁰ bytes |
1. Shannon, Claude E. "A Symbolic Analysis of Relay and Switching Circuits." 1938.
2. von Neumann, John. "First Draft of a Report on the EDVAC." 1945.
3. Knuth, Donald E. "The Art of Computer Programming, Volume 2: Seminumerical Algorithms." Addison-Wesley. 1997.
4. IEEE Standard for Floating-Point Arithmetic (IEEE 754). 2019.
5. Tanenbaum, Andrew S. "Structured Computer Organization." Pearson. 2012.
6. Boole, George. "The Mathematical Analysis of Logic." 1847.