Binary Encyclopedia Digital Logic & Computing
The binary system is the fundamental language of modern computing. It is a base-2 positional notation system that uses only two symbols: 0 and 1. This system is chosen for digital electronics because it is the most reliable way to represent "on" and "off" states in electrical circuits.
Signed Numbers & Two's Complement
In computing, negative numbers are typically represented using Two's Complement. This method is superior because it allows the computer to perform subtraction using the same hardware circuitry as addition. To find the Two's Complement of a number:
1. Write the positive value in binary (e.g., 5 is 00000101)
2. Invert all bits (0 becomes 1, 1 becomes 0: 11111010)
3. Add 1 to the result: 11111011 (which represents -5)
Bitwise Operations
Bitwise operations act directly on individual bits. They are extremely fast and are used for low-level optimizations, graphics, and networking protocols.
- AND (&): Result is 1 only if both bits are 1.
- OR (|): Result is 1 if at least one bit is 1.
- XOR (^): Result is 1 if the bits are different.
- NOT (~): Inverts all bits (logical negation).
Manual Conversion Algorithms
Decimal to Binary: Repeated Division
Divide the decimal number by 2 and record the remainder. Continue dividing the quotient by 2 until you reach 0. Read the remainders in reverse order.
Example for 13:
13 / 2 = 6 with remainder 1
6 / 2 = 3 with remainder 0
3 / 2 = 1 with remainder 1
1 / 2 = 0 with remainder 1
Binary result: 1101
Binary to Decimal: Positional Weighting
Multiply each bit by 2 raised to the power of its position (starting from 0 on the right) and sum the results.
Example for 1101:
(1 \u00D7 2\u00B3) + (1 \u00D7 2\u00B2) + (0 \u00D7 2\u00B1) + (1 \u00D7 2\u2070)
= 8 + 4 + 0 + 1
= 13
Bit Length & Overflow
Computer hardware processes binary in fixed-size "containers" such as 8-bit (Byte), 32-bit, or 64-bit words. When a calculation exceeds the maximum capacity of its container, an Overflow occurs.
Standard for basic color channels (RGB).
Historical standard for legacy computing systems.
The foundation for modern IPv4 addressing and architecture.
Logical Shifting
Left shifts (<<) and Right shifts (>>) are powerful mathematical shortcuts. In binary, a Left Shift by one position effectively multiplies a number by 2, while a Right Shift divides it by 2. This is critical for high-performance graphics and encryption.
Why Master Binary?
Understanding binary helps you grasp how computers manage memory, process instructions, and communicate over network protocols like TCP/IP. It is the bridge between being a "user" and becoming a "developer."