1. The Structure of Number Bases
Every number system has a "radix" or "base" which defines the number of unique symbols used to write numbers. The decimal system (base-10) uses ten symbols (0-9). The binary system (base-2) uses two symbols (0 and 1).
In any base, a number can be written as a sum of digits multiplied by the base raised to a power. The general formula for a positional number is: $$N = \sum_{i=0}^{k} d_i \times B^i$$ where: - $d_i$ is the digit at position $i$ - $B$ is the base (radix) - $i$ is the position index starting at 0 from the right.
2. Understanding MSB and LSB Significance
In a binary sequence, the position of each bit determines its significance: - Least Significant Bit (LSB): The rightmost bit in a binary number. It has the lowest weight ($2^0 = 1$). The LSB determines whether a binary number is odd or even. If the LSB is 1, the number is odd; if the LSB is 0, the number is even. - Most Significant Bit (MSB): The leftmost bit in a binary number. It carries the highest weight. In signed integer representation (such as two's complement), the MSB serves as the sign bit (0 for positive, 1 for negative).
3. Signed vs Unsigned Binary Integers
Unsigned binary integers represent only positive numbers and zero. However, computers must also represent negative numbers. There are three common ways to do this: 1. Sign-Magnitude: The MSB represents the sign (0 = positive, 1 = negative), while the remaining bits represent the magnitude. This method has a major drawback: it creates two representations for zero (+0 and -0), which complicates ALU hardware design. 2. One's Complement: Negative numbers are created by inverting all the bits of the positive number. It also suffers from dual representations of zero. 3. Two's Complement: The standard format in modern computing. To find the two's complement of a negative number, invert all bits of the positive number and add 1. This system eliminates dual zeros and allows the CPU to perform subtraction using standard addition circuits.
4. Floating-Point Binary Representation
To represent real fractional numbers (like 12.34), computers use the IEEE 754 floating-point standard. A floating-point number is divided into three components: - Sign Bit: 1 bit representing positive or negative. - Exponent: Defines the scale of the number. - Mantissa (Fraction): Stores the significant digits of the number. This allows computers to represent extremely large or small numbers in a fixed size (e.g. 32-bit single precision or 64-bit double precision).