No history yet

Positional Binary Logic

The Power of Position

In the decimal system we use daily, a digit's value depends on its place. The '7' in 700 is worth a hundred times more than the '7' in the number 7. Binary works the same way, but instead of powers of ten, it uses powers of two.

Each position in a binary number represents a power of two, starting from $2^0$ on the far right. To find the decimal value of a binary number, you multiply each bit by its corresponding power of two and add up the results.

Position4321
Power of Two232^3222^2212^1202^0
Decimal Value8421

Let's take the binary number 1101. Reading from right to left, we have a 1 in the ones place, a 0 in the twos place, a 1 in the fours place, and a 1 in the eights place.

(1×23)+(1×22)+(0×21)+(1×20)(1 \times 2^3) + (1 \times 2^2) + (0 \times 2^1) + (1 \times 2^0)
8+4+0+1=138 + 4 + 0 + 1 = 13

Building with Bits

While a single bit is the smallest unit of data, computers rarely handle bits one by one. They group them into larger, standardized chunks. The most common is the byte, which is a sequence of eight bits.

A smaller, less common unit is the nibble—a group of four bits. It's exactly half a byte.

The number of bits used to represent a number is its bit-depth. An 8-bit number (a byte) can represent $2^8$, or 256, distinct values (from 0 to 255). A 16-bit number can represent $2^{16}$, or 65,536 values. This bit-depth sets a hard limit on the maximum value a single data unit can hold.

In a computer's processor, the native unit of data is called a word. The reflects the architecture of the CPU. A 32-bit CPU processes data in 32-bit words, while a 64-bit CPU uses 64-bit words. A larger word size means the processor can handle more data in a single operation, which generally leads to faster performance.

Order in Memory

When a computer stores a number that's larger than a single byte, like a 32-bit word, it has to decide which order to store the bytes in memory. Imagine the 32-bit number 0x0A0B0C0D (hexadecimal for clarity), which consists of four bytes: 0A, 0B, 0C, and 0D.

A computer system could store these bytes starting with the most significant byte (0A) or the least significant byte (0D). This choice is called endianness.

Big-Endian: Stores the most significant byte first, at the lowest memory address. It's like writing a number the way we naturally read it, from left to right. The bytes would be stored in memory as 0A, 0B, 0C, 0D.

Little-Endian: Stores the least significant byte first. The bytes would be stored as 0D, 0C, 0B, 0A. This might seem backward, but it can simplify certain arithmetic operations at the hardware level.

Most modern CPUs, like those from Intel and AMD, are architectures. However, big-endian is common in networking protocols. When different systems communicate, they must agree on an endianness to avoid misinterpreting data. This is why understanding the physical layout of data in memory is crucial, moving binary from abstract math to the reality of hardware.

Let's check your understanding of these core concepts.

Quiz Questions 1/6

What is the decimal equivalent of the binary number 1011?

Quiz Questions 2/6

A 'byte' is a sequence of eight bits.

With this foundation, you can see how simple 0s and 1s are organized to represent complex data inside a computer.