PROJECTENGRAM

[PS] BINARY DATA ORGANIZATION

Problem Set: Binary Data Organization

Tags: #◇Computer Science #◇CSARCH2 #◇Problem Sets #◇Binary Organization #◇Endianness #◇Memory Architecture #◇Data Units


◇Overview

In modern computer systems, memory is organized as a linear array of byte-addressable storage cells. To manage information efficiently, processor architectures define standardized data units—ranging from individual bits to multi-byte words—and conventions for ordering these units in physical memory.

This problem set explores three core architectural topics:

  1. Byte Ordering / Endianness: How multi-byte words are stored across sequential byte addresses in Little-Endian vs. Big-Endian architectures.
  2. Significance Hierarchies: Identifying the Most Significant (MS) and Least Significant (LS) components across bits, nibbles, bytes, and words.
  3. Storage Prefixes (2x vs. 10y2^x \text{ vs. } 10^y): Quantifying data capacity differences between decimal SI units (GB\text{GB}) and binary IEC units (GiB\text{GiB}).

◇Theoretical Foundations

1. Data Unit Hierarchy

UnitSymbol / AbbreviationSize in BitsSize in BytesHexadecimal Representation
Bitb\text{b}1 bit1\text{ bit}1/8 byte1/8\text{ byte}Single binary digit (00 or 11)
Nibble—4 bits4\text{ bits}0.5 byte0.5\text{ byte}1 hex digit1\text{ hex digit} (0−F0-\text{F})
ByteB\text{B}8 bits8\text{ bits}1 byte1\text{ byte}2 hex digits2\text{ hex digits} (00−FF00-\text{FF})
Halfword (typical)H\text{H}16 bits16\text{ bits}2 bytes2\text{ bytes}4 hex digits4\text{ hex digits}
Word (standard 32-bit architecture)W\text{W}32 bits32\text{ bits}4 bytes4\text{ bytes}8 hex digits8\text{ hex digits}
Doubleword / QuadwordD / Q\text{D / Q}64 bits64\text{ bits}8 bytes8\text{ bytes}16 hex digits16\text{ hex digits}

Note on Architecture Terminology: While x86 legacy terminology originally defined a "word" as 16 bits, modern 32-bit architectures (and the explicit assumption in this problem set) define a word as 32 bits (4 bytes).


2. Byte Ordering (Endianness)

When a numeric datum spanning kk bytes with value V=∑i=0k−1Bi⋅256iV = \sum_{i=0}^{k-1} B_i \cdot 256^i (where B0B_0 is the Least Significant Byte and Bk−1B_{k-1} is the Most Significant Byte) is stored starting at base memory address AA:

『』
TEXT
Value: [ B_{k-1} (MSB) ] ... [ B_2 ] [ B_1 ] [ B_0 (LSB) ]
  • Little-Endian (LE): The Least Significant Byte (LSB) is stored at the lowest memory address (AA). Successive bytes of increasing significance are stored at increasing addresses:
    Address(A+i)=Bifor i=0,1,…,k−1\text{Address}(A + i) = B_i \quad \text{for } i = 0, 1, \dots, k-1
    ValueLE=∑i=0k−1Memory[A+i]⋅256i\text{Value}_{\text{LE}} = \sum_{i=0}^{k-1} \text{Memory}[A + i] \cdot 256^i
    (Common in x86, x86-64, RISC-V default).

  • Big-Endian (BE): The Most Significant Byte (MSB) is stored at the lowest memory address (AA). Successive bytes of decreasing significance are stored at increasing addresses:
    Address(A+i)=Bk−1−ifor i=0,1,…,k−1\text{Address}(A + i) = B_{k-1 - i} \quad \text{for } i = 0, 1, \dots, k-1
    ValueBE=∑i=0k−1Memory[A+i]⋅256k−1−i\text{Value}_{\text{BE}} = \sum_{i=0}^{k-1} \text{Memory}[A + i] \cdot 256^{k - 1 - i}
    (Common in IBM z/Architecture, network protocols / TCP/IP "network byte order", Motorola 68k).


3. Metric (SI) vs. Binary (IEC) Prefixes

  • Decimal SI Prefixes (10y10^y): Standardized by the International System of Units (SI).
    1 Kilobyte (KB)=103 B=1,000 B1\text{ Kilobyte (KB)} = 10^3\text{ B} = 1{,}000\text{ B}
    1 Megabyte (MB)=106 B=1,000,000 B1\text{ Megabyte (MB)} = 10^6\text{ B} = 1{,}000{,}000\text{ B}
    1 Gigabyte (GB)=109 B=1,000,000,000 B1\text{ Gigabyte (GB)} = 10^9\text{ B} = 1{,}000{,}000{,}000\text{ B}
    1 Terabyte (TB)=1012 B=1,000,000,000,000 B1\text{ Terabyte (TB)} = 10^{12}\text{ B} = 1{,}000{,}000{,}000{,}000\text{ B}

  • Binary IEC Prefixes (2x2^x): Standardized by the International Electrotechnical Commission (IEC 60027-2).
    1 Kibibyte (KiB)=210 B=1,024 B1\text{ Kibibyte (KiB)} = 2^{10}\text{ B} = 1{,}024\text{ B}
    1 Mebibyte (MiB)=220 B=1,048,576 B1\text{ Mebibyte (MiB)} = 2^{20}\text{ B} = 1{,}048{,}576\text{ B}
    1 Gibibyte (GiB)=230 B=1,073,741,824 B1\text{ Gibibyte (GiB)} = 2^{30}\text{ B} = 1{,}073{,}741{,}824\text{ B}
    1 Tebibyte (TiB)=240 B=1,099,511,627,776 B1\text{ Tebibyte (TiB)} = 2^{40}\text{ B} = 1{,}099{,}511{,}627{,}776\text{ B}


◇Detailed Step-by-Step Problem Solutions

Reference Memory Map for Problems 1 & 2

The table below describes the physical byte contents of memory from address 0x0000 to 0x000B:

Address (Hex)Address (Dec)Data Byte (Hex)Binary Byte
0x000B11110x891000 1001
0x000A10100x670110 0111
0x0009990x450100 0101
0x0008880x230010 0011
0x0007770xF11111 0001
0x0006660xDE1101 1110
0x0005550xBC1011 1100
0x0004440x9A1001 1010
0x0003330x780111 1000
0x0002220x560101 0110
0x0001110x340011 0100
0x0000000x120001 0010

Problem 1: Little Endian Data Reconstruction

In Little Endian, the byte at base address AA is the Least Significant Byte (LSB), and subsequent addresses contain higher-significance bytes.

1.a) 2-Byte (Halfword) Data at Address 0x0A

  • Given:
    • Base Address A=0x000AA = \text{0x000A}
    • Size k=2 bytesk = 2\text{ bytes} (spans addresses 0x000A\text{0x000A} and 0x000B\text{0x000B})
  • Address-to-Significance Mapping:
    Byte 0 (LSB, weight 2560)→Memory[0x000A]=0x67Byte 1 (MSB, weight 2561)→Memory[0x000B]=0x89\begin{aligned} \text{Byte 0 (LSB, } \text{weight } 256^0\text{)} &\to \text{Memory}[\text{0x000A}] = \text{0x67} \\ \text{Byte 1 (MSB, } \text{weight } 256^1\text{)} &\to \text{Memory}[\text{0x000B}] = \text{0x89} \end{aligned}
  • Reconstruction:
    Value=(Byte 1≪8)+Byte 0=(0x89×256)+0x67=0x8967\text{Value} = (\text{Byte 1} \ll 8) + \text{Byte 0} = (\text{0x89} \times 256) + \text{0x67} = \mathbf{\text{0x8967}}

Answer: 0x8967\mathbf{\text{Answer: 0x8967}}


1.b) 4-Byte (Word) Data at Address 4 (0x0004)

  • Given:
    • Base Address A=0x0004A = \text{0x0004}
    • Size k=4 bytesk = 4\text{ bytes} (spans addresses 0x0004,0x0005,0x0006,0x0007\text{0x0004}, \text{0x0005}, \text{0x0006}, \text{0x0007})
  • Address-to-Significance Mapping:
    Byte 0 (LSB, weight 2560)→Memory[0x0004]=0x9AByte 1 (weight 2561)→Memory[0x0005]=0xBCByte 2 (weight 2562)→Memory[0x0006]=0xDEByte 3 (MSB, weight 2563)→Memory[0x0007]=0xF1\begin{aligned} \text{Byte 0 (LSB, } \text{weight } 256^0\text{)} &\to \text{Memory}[\text{0x0004}] = \text{0x9A} \\ \text{Byte 1 (weight } 256^1\text{)} &\to \text{Memory}[\text{0x0005}] = \text{0xBC} \\ \text{Byte 2 (weight } 256^2\text{)} &\to \text{Memory}[\text{0x0006}] = \text{0xDE} \\ \text{Byte 3 (MSB, } \text{weight } 256^3\text{)} &\to \text{Memory}[\text{0x0007}] = \text{0xF1} \end{aligned}
  • Reconstruction:
    Value=(Byte 3≪24)+(Byte 2≪16)+(Byte 1≪8)+Byte 0=(0xF1×224)+(0xDE×216)+(0xBC×28)+0x9A=0xF1DEBC9A\begin{aligned} \text{Value} &= (\text{Byte 3} \ll 24) + (\text{Byte 2} \ll 16) + (\text{Byte 1} \ll 8) + \text{Byte 0} \\ &= (\text{0xF1} \times 2^{24}) + (\text{0xDE} \times 2^{16}) + (\text{0xBC} \times 2^8) + \text{0x9A} \\ &= \mathbf{\text{0xF1DEBC9A}} \end{aligned}

Answer: 0xF1DEBC9A\mathbf{\text{Answer: 0xF1DEBC9A}}


Problem 2: Big Endian Data Reconstruction

In Big Endian, the byte at base address AA is the Most Significant Byte (MSB), and bytes are read sequentially from left to right as written naturally.

2.c) 4-Byte (Word) Data at Address 8 (0x0008)

  • Given:
    • Base Address A=0x0008A = \text{0x0008}
    • Size k=4 bytesk = 4\text{ bytes} (spans addresses 0x0008,0x0009,0x000A,0x000B\text{0x0008}, \text{0x0009}, \text{0x000A}, \text{0x000B})
  • Address-to-Significance Mapping:
    Byte 3 (MSB, weight 2563)→Memory[0x0008]=0x23Byte 2 (weight 2562)→Memory[0x0009]=0x45Byte 1 (weight 2561)→Memory[0x000A]=0x67Byte 0 (LSB, weight 2560)→Memory[0x000B]=0x89\begin{aligned} \text{Byte 3 (MSB, } \text{weight } 256^3\text{)} &\to \text{Memory}[\text{0x0008}] = \text{0x23} \\ \text{Byte 2 (weight } 256^2\text{)} &\to \text{Memory}[\text{0x0009}] = \text{0x45} \\ \text{Byte 1 (weight } 256^1\text{)} &\to \text{Memory}[\text{0x000A}] = \text{0x67} \\ \text{Byte 0 (LSB, } \text{weight } 256^0\text{)} &\to \text{Memory}[\text{0x000B}] = \text{0x89} \end{aligned}
  • Reconstruction:
    Value=(Byte 3≪24)+(Byte 2≪16)+(Byte 1≪8)+Byte 0=0x23456789\begin{aligned} \text{Value} &= (\text{Byte 3} \ll 24) + (\text{Byte 2} \ll 16) + (\text{Byte 1} \ll 8) + \text{Byte 0} \\ &= \mathbf{\text{0x23456789}} \end{aligned}

Answer: 0x23456789\mathbf{\text{Answer: 0x23456789}}


2.d) 8-Byte (Doubleword) Data at Address 0 (0x0000)

  • Given:
    • Base Address A=0x0000A = \text{0x0000}
    • Size k=8 bytesk = 8\text{ bytes} (spans addresses 0x0000\text{0x0000} through 0x0007\text{0x0007})
  • Address-to-Significance Mapping:
    Byte 7 (MSB, weight 2567)→Memory[0x0000]=0x12Byte 6 (weight 2566)→Memory[0x0001]=0x34Byte 5 (weight 2565)→Memory[0x0002]=0x56Byte 4 (weight 2564)→Memory[0x0003]=0x78Byte 3 (weight 2563)→Memory[0x0004]=0x9AByte 2 (weight 2562)→Memory[0x0005]=0xBCByte 1 (weight 2561)→Memory[0x0006]=0xDEByte 0 (LSB, weight 2560)→Memory[0x0007]=0xF1\begin{aligned} \text{Byte 7 (MSB, } \text{weight } 256^7\text{)} &\to \text{Memory}[\text{0x0000}] = \text{0x12} \\ \text{Byte 6 (weight } 256^6\text{)} &\to \text{Memory}[\text{0x0001}] = \text{0x34} \\ \text{Byte 5 (weight } 256^5\text{)} &\to \text{Memory}[\text{0x0002}] = \text{0x56} \\ \text{Byte 4 (weight } 256^4\text{)} &\to \text{Memory}[\text{0x0003}] = \text{0x78} \\ \text{Byte 3 (weight } 256^3\text{)} &\to \text{Memory}[\text{0x0004}] = \text{0x9A} \\ \text{Byte 2 (weight } 256^2\text{)} &\to \text{Memory}[\text{0x0005}] = \text{0xBC} \\ \text{Byte 1 (weight } 256^1\text{)} &\to \text{Memory}[\text{0x0006}] = \text{0xDE} \\ \text{Byte 0 (LSB, } \text{weight } 256^0\text{)} &\to \text{Memory}[\text{0x0007}] = \text{0xF1} \end{aligned}
  • Reconstruction:
    Value=0x12⋅2567+0x34⋅2566+⋯+0xF1⋅2560=0x123456789ABCDEF1\begin{aligned} \text{Value} &= \text{0x12} \cdot 256^7 + \text{0x34} \cdot 256^6 + \dots + \text{0xF1} \cdot 256^0 \\ &= \mathbf{\text{0x123456789ABCDEF1}} \end{aligned}

Answer: 0x123456789ABCDEF1\mathbf{\text{Answer: 0x123456789ABCDEF1}}


Problem 3: Most / Least Significant Units

Given Data: 0x58ABCDEF12345679\text{0x58ABCDEF12345679}

  • Total size: 16 hex digits=64 bits=8 bytes=2 words16\text{ hex digits} = 64\text{ bits} = 8\text{ bytes} = 2\text{ words} (where 1 word≡32 bits1\text{ word} \equiv 32\text{ bits}).

Complete Structural Breakdown of 0x58ABCDEF12345679:

『』
TEXT
Hex Digits:    5    8    A    B    C    D    E    F    1    2    3    4    5    6    7    9
Nibble Index: N15  N14  N13  N12  N11  N10  N9   N8   N7   N6   N5   N4   N3   N2   N1   N0
Byte Index:   [     Byte 7     ]  [     Byte 6     ]  [     Byte 5     ]  [     Byte 4     ]  [     Byte 3     ]  [     Byte 2     ]  [     Byte 1     ]  [     Byte 0     ]
Word Index:   [                   Word 1 (Most Significant Word)                   ]  [                   Word 0 (Least Significant Word)                  ]

Full binary representation:
0101⏟5  1000⏟8  1010⏟A  1011⏟B  1100⏟C  1101⏟D  1110⏟E  1111⏟F  0001⏟1  0010⏟2  0011⏟3  0100⏟4  0101⏟5  0110⏟6  0111⏟7  1001⏟9\underbrace{0101}_{5} \; \underbrace{1000}_{8} \; \underbrace{1010}_{\text{A}} \; \underbrace{1011}_{\text{B}} \; \underbrace{1100}_{\text{C}} \; \underbrace{1101}_{\text{D}} \; \underbrace{1110}_{\text{E}} \; \underbrace{1111}_{\text{F}} \; \underbrace{0001}_{1} \; \underbrace{0010}_{2} \; \underbrace{0011}_{3} \; \underbrace{0100}_{4} \; \underbrace{0101}_{5} \; \underbrace{0110}_{6} \; \underbrace{0111}_{7} \; \underbrace{1001}_{9}


3.a) Least Significant Bit (LSb)

  • Definition: Bit index b0b_0 (the rightmost bit in the full binary string).
  • Calculation: The least significant hex digit is 0x9=10012\text{0x9} = 1001_2.
    The lowest bit (b0b_0) is 11.
    Answer: 1(or 12)\mathbf{\text{Answer: } 1 \quad (\text{or } 1_2)}

3.b) Most Significant Bit (MSb)

  • Definition: Bit index b63b_{63} (the leftmost bit in the full binary string).
  • Calculation: The most significant hex digit is 0x5=01012\text{0x5} = 0101_2.
    The highest bit (b63b_{63}) is 00.
    Answer: 0(or 02)\mathbf{\text{Answer: } 0 \quad (\text{or } 0_2)}

3.c) Least Significant Nibble (LSN)

  • Definition: The rightmost 4 bits4\text{ bits} (Nibble N0N_0).
  • Calculation: Corresponding to hex digit index 00.
    Answer: 0x9(or 916=10012)\mathbf{\text{Answer: 0x9} \quad (\text{or } 9_{16} = 1001_2)}

3.d) Most Significant Nibble (MSN)

  • Definition: The leftmost 4 bits4\text{ bits} (Nibble N15N_{15}).
  • Calculation: Corresponding to hex digit index 1515.
    Answer: 0x5(or 516=01012)\mathbf{\text{Answer: 0x5} \quad (\text{or } 5_{16} = 0101_2)}

3.e) Least Significant Byte (LSB)

  • Definition: The rightmost 8 bits8\text{ bits} / 2 hex digits2\text{ hex digits} (Byte B0B_0).
  • Calculation: Formed by nibbles N1N0=0x79N_1 N_0 = \text{0x79}.
    Answer: 0x79(or 7916=011110012)\mathbf{\text{Answer: 0x79} \quad (\text{or } 79_{16} = 01111001_2)}

3.f) Most Significant Byte (MSB)

  • Definition: The leftmost 8 bits8\text{ bits} / 2 hex digits2\text{ hex digits} (Byte B7B_7).
  • Calculation: Formed by nibbles N15N14=0x58N_{15} N_{14} = \text{0x58}.
    Answer: 0x58(or 5816=010110002)\mathbf{\text{Answer: 0x58} \quad (\text{or } 58_{16} = 01011000_2)}

3.g) Least Significant Word (LSW)

  • Definition: The rightmost 32 bits32\text{ bits} / 4 bytes4\text{ bytes} / 8 hex digits8\text{ hex digits} (Word W0W_0).
  • Calculation: Formed by bytes B3B2B1B0=0x12345679B_3 B_2 B_1 B_0 = \text{0x12345679}.
    Answer: 0x12345679\mathbf{\text{Answer: 0x12345679}}

3.h) Most Significant Word (MSW)

  • Definition: The leftmost 32 bits32\text{ bits} / 4 bytes4\text{ bytes} / 8 hex digits8\text{ hex digits} (Word W1W_1).
  • Calculation: Formed by bytes B7B6B5B4=0x58ABCDEFB_7 B_6 B_5 B_4 = \text{0x58ABCDEF}.
    Answer: 0x58ABCDEF\mathbf{\text{Answer: 0x58ABCDEF}}

Problems 4 & 5: 2x vs. 10y2^x \text{ vs. } 10^y (Storage Prefixes)

Problem 4: 2 Gigabytes (GB)

  • SI Standard (Decimal Prefix 10910^9):
    Prefix Definition:1 Giga (G)=109=1,000,000,000Total Bytes:2 GB=2×109 bytes=2,000,000,000 bytesTotal Bits:2,000,000,000×8 bits=16×109 bits=16,000,000,000 bits=1.6×1010 bits(16 Gbits)\begin{aligned} \text{Prefix Definition:} \quad 1\text{ Giga (G)} &= 10^9 = 1{,}000{,}000{,}000 \\ \text{Total Bytes:} \quad 2\text{ GB} &= 2 \times 10^9\text{ bytes} = \mathbf{2{,}000{,}000{,}000\text{ bytes}} \\ \text{Total Bits:} \quad 2{,}000{,}000{,}000 \times 8\text{ bits} &= 16 \times 10^9\text{ bits} = \mathbf{16{,}000{,}000{,}000\text{ bits}} \\ &= 1.6 \times 10^{10}\text{ bits} \quad (16\text{ Gbits}) \end{aligned}

  • Comparative Context (Legacy JEDEC Convention):
    Historically, operating systems and memory manufacturers sometimes used "GB" to mean 230 bytes2^{30}\text{ bytes}. Under JEDEC:
    2 GBJEDEC=2×230 B=2,147,483,648 bytes,17,179,869,184 bits2\text{ GB}_{\text{JEDEC}} = 2 \times 2^{30}\text{ B} = 2{,}147{,}483{,}648\text{ bytes}, \quad 17{,}179{,}869{,}184\text{ bits}


Problem 5: 2 Gibibytes (GiB)

  • IEC Standard (Binary Prefix 2302^{30}):
    Prefix Definition:1 Gibi (Gi)=230=1,073,741,824Total Bytes:2 GiB=2×230 bytes=231 bytes=2,147,483,648 bytesTotal Bits:231 bytes×8 bits/byte=231×23 bits=234 bits=17,179,869,184 bits(16 Gibits)\begin{aligned} \text{Prefix Definition:} \quad 1\text{ Gibi (Gi)} &= 2^{30} = 1{,}073{,}741{,}824 \\ \text{Total Bytes:} \quad 2\text{ GiB} &= 2 \times 2^{30}\text{ bytes} = 2^{31}\text{ bytes} \\ &= \mathbf{2{,}147{,}483{,}648\text{ bytes}} \\ \text{Total Bits:} \quad 2^{31}\text{ bytes} \times 8\text{ bits/byte} &= 2^{31} \times 2^3\text{ bits} = 2^{34}\text{ bits} \\ &= \mathbf{17{,}179{,}869{,}184\text{ bits}} \quad (16\text{ Gibits}) \end{aligned}

Prefix Comparison Summary Table

Metric2 Gigabytes (GB, SI)2 Gibibytes (GiB, IEC)Absolute DifferencePercentage Difference
Base Formula (Bytes)2×109 B2 \times 10^9\text{ B}2×230 B=231 B2 \times 2^{30}\text{ B} = 2^{31}\text{ B}231−2⋅1092^{31} - 2\cdot 10^9—
Exact Bytes2,000,000,000 B\mathbf{2{,}000{,}000{,}000\text{ B}}2,147,483,648 B\mathbf{2{,}147{,}483{,}648\text{ B}}+147,483,648 B+147{,}483{,}648\text{ B}≈+7.374%\approx +7.374\%
Base Formula (Bits)16×109 b16 \times 10^9\text{ b}234 b2^{34}\text{ b}234−16⋅1092^{34} - 16\cdot 10^9—
Exact Bits16,000,000,000 b\mathbf{16{,}000{,}000{,}000\text{ b}}17,179,869,184 b\mathbf{17{,}179{,}869{,}184\text{ b}}+1,179,869,184 b+1{,}179{,}869{,}184\text{ b}≈+7.374%\approx +7.374\%

◇Key Takeaways & Exam Summary

  1. Endianness Rapid Evaluation:

    • In Little Endian, memory address AA holds the lowest byte (B0B_0). Read memory backwards (from high address down to low address) to write out the hexadecimal value in standard human notation.
    • In Big Endian, memory address AA holds the highest byte (BMSBB_{\text{MSB}}). Read memory forwards (from low address up to high address) directly as written in standard human notation.
  2. Significance Hierarchy:

    • Bit: 11 binary digit.
    • Nibble: 11 hex digit (44 bits).
    • Byte: 22 hex digits (88 bits).
    • Word (32-bit): 88 hex digits (44 bytes / 3232 bits).
    • LS units are always on the rightmost end; MS units are always on the leftmost end.
  3. Storage Discrepancy:

    • As capacity scales from kilo- to tera-, the gap between SI (103k10^{3k}) and IEC (210k2^{10k}) expands:
  • Kilo vs. Kibi: ≈2.4%\approx 2.4\% difference
  • Mega vs. Mebi: ≈4.86%\approx 4.86\% difference
  • Giga vs. Gibi: ≈7.37%\approx 7.37\% difference
  • Tera vs. Tebi: ≈9.95%\approx 9.95\% difference
    • This difference explains why a hard drive advertised as 2 TB2\text{ TB} (2×1012 B2 \times 10^{12}\text{ B}) appears as only ≈1.818 TiB\approx 1.818\text{ TiB} in operating systems that measure in binary units.

◇References & Navigation

[PS] Binary Data Organization | PROJECT ENGRAM