Why Computers Use Binary
At their physical level, modern digital computers consist of billions of microscopic transistors acting as electronic switches. These switches have two stable states: ON (represented as logical 1, typically high voltage) and OFF (represented as logical 0, typically low voltage). Because of this binary nature, all data—including numbers, text, images, and audio—must be digitized into binary representations.
1. Positional Number Systems
A positional number system represents numeric values using digits whose positional weight is a power of the base (radix):
- Decimal (Base 10): Digits 0 to 9. Weights: 10^0, 10^1, 10^2...
- Binary (Base 2): Digits 0 and 1. Weights: 2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16...
- Octal (Base 8): Digits 0 to 7. One octal digit groups 3 binary bits.
- Hexadecimal (Base 16): Digits 0-9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). One hex digit groups 4 binary bits (a nibble).
2. Converting Between Bases
Decimal to Binary (Division by 2 Method)
To convert a decimal number to binary, divide repeatedly by 2 and collect the remainders from bottom to top (Least Significant Bit to Most Significant Bit).
Binary to Hexadecimal Conversion
Group binary digits into sets of 4 starting from the rightmost bit (decimal point for fractions):
Binary: 1101 0110 Hex: D 6 -> D6 (Base 16)3. Representing Signed Integers: Two's Complement
In computing, negative numbers cannot be represented simply with a minus sign. Three methods exist for signed integer representation:
- Sign and Magnitude: The leftmost bit denotes sign (0 = positive, 1 = negative), remaining bits denote magnitude. Disadvantage: Two representations for zero (+0 and -0).
- One's Complement: Invert all bits of the positive number. Disadvantage: Still has +0 and -0 issues and complex hardware addition.
- Two's Complement (Standard): To find the 2's complement of a negative number:
- Write the positive number in binary with the target bit-width (e.g., 8 bits).
- Invert all bits (0 becomes 1, 1 becomes 0).
- Add 1 to the result.
Example: Representing -25 in 8-bit Two's Complement
- Positive 25 in 8-bit binary: 0001 1001
- Invert bits (1's complement): 1110 0110
- Add 1: 1110 0110 + 1 = 1110 0111
Thus, -25 in 8-bit two's complement is 11100111.
.webp)



