Unit 4: Number Systems

CSE111 — Orientation To Computing 7 min read

I. Orientation — Positional Representation of Numbers

A number system is a structured method of representing quantities with symbols called digits. Modern computing relies mainly on positional number systems, in which a digit’s value depends on both the digit itself and its position. Each system is identified by its base or radix.

A. Foundations and Conventions

Positional notation provides the common principle needed to understand binary, decimal, octal, hexadecimal, and conversions among them.

  • Base or radix: A base (b) system uses (b) distinct digits, from (0) through (b-1). Binary has base (2), while hexadecimal has base (16).
  • Place value: Positions are powers of the base. For an integer, powers increase from right to left; after the radix point, powers decrease from left to right.
  • General form: A positional number can be evaluated using:
TEXT
(dₙdₙ₋₁...d₁d₀.d₋₁d₋₂...)ᵦ = Σ dᵢ × bⁱ
  • (b) is the base.
  • (d_i) is the digit at position (i), where (0 \le d_i < b).
  • (i=0) identifies the units position; negative values identify fractional positions.
    • Radix point: The separator between integer and fractional parts is called the radix point. It is a decimal point specifically when the base is (10).
    • Base notation: A subscript prevents ambiguity. Thus, (10102=10{10}), whereas (1010_{10}) means one thousand ten.
    • Most and least significant digits:
  • The leftmost nonzero digit has the greatest positional weight and is the most significant digit.
  • The rightmost digit has the smallest displayed weight and is the least significant digit.
    • Leading and trailing zeros: Leading zeros do not alter an integer’s value, so (00101_2=1012). Zeros after a fractional digit may show precision, as in (2.50{10}).
    • Negative numbers: A minus sign may indicate a negative mathematical value, such as (-101_2). Computers may instead use encodings such as two’s complement.

II. Binary — Base 2

A. Binary

Binary is a base-(2) positional system that represents all values using only the digits (0) and (1).

  • Digit set: The valid binary digits, or bits, are (0) and (1). A numeral such as (1021_2) is invalid because binary has no digit (2).
  • Place weights: Binary integer positions have weights (1,2,4,8,16,\ldots), corresponding to (2^0,2^1,2^2,2^3,2^4,\ldots).
  • Fractional weights: Positions after the binary point have weights (2^{-1},2^{-2},2^{-3},\ldots), equal to (1/2,1/4,1/8,\ldots).
  • Worked example: The value of (1011.01_2) is obtained by expanding its place values:
TEXT
1011.01₂
= 1×2³ + 0×2² + 1×2¹ + 1×2⁰ + 0×2⁻¹ + 1×2⁻²
= 8 + 0 + 2 + 1 + 0 + 0.25
= 11.25₁₀
  • Bit groupings: Four bits form a nibble, while eight bits commonly form a byte. For example, (11001010_2) occupies one byte.
  • Binary arithmetic: Fundamental addition rules include (0+0=0), (0+1=1), (1+1=10_2), and (1+1+1=11_2).

B. Applications and Limitations

Binary matches the two-state operation of digital electronic components.

  • Physical representation: A bit may be implemented through low/high voltage, off/on transistor states, or unmagnetized/magnetized storage states.
  • Logical operations: Boolean values map naturally to binary: (0) commonly represents false and (1) represents true.
  • Data encoding: Instructions, text, images, and sound are ultimately stored as bit patterns; their meanings depend on an encoding standard or file format.
  • Readability limitation: Binary numerals become long. The decimal value (255_{10}), for example, requires eight binary digits: (11111111_2).

III. Decimal — Base 10

A. Decimal

Decimal is the base-(10) positional system used for ordinary counting, measurement, and human-readable numerical communication.

  • Digit set: Decimal uses (0,1,2,3,4,5,6,7,8,9).
  • Place weights: Integer positions represent (10^0,10^1,10^2,\ldots), giving units, tens, hundreds, and higher powers.
  • Fractional weights: Decimal places represent tenths, hundredths, thousandths, and so on: (10^{-1},10^{-2},10^{-3},\ldots).
  • Worked example: The numeral (4,307.25_{10}) expands as:
TEXT
4×10³ + 3×10² + 0×10¹ + 7×10⁰ + 2×10⁻¹ + 5×10⁻²
= 4000 + 300 + 0 + 7 + 0.2 + 0.05
= 4307.25
  • Scientific notation: Powers of ten compactly express very large or small values. For example, (6.25\times10^4=62,500).

B. Applications and Limitations

Decimal is convenient for people but does not correspond directly to the two-state structure of digital hardware.

  • User interaction: Input and output are normally displayed in decimal even when the computer internally stores values in binary.
  • Storage limitation: Some finite decimal fractions have repeating binary representations. For example, (0.1_{10}) cannot be represented exactly by a finite binary fraction.
  • Rounding effects: Binary floating-point approximation can make a computed result differ slightly from the expected decimal value, especially across repeated calculations.
  • Specialized decimal storage: Financial software may use decimal floating-point or fixed-point formats when exact decimal cents are required.

IV. Octal — Base 8

A. Octal

Octal is a base-(8) positional system that provides a compact representation of binary values.

  • Digit set: Octal uses (0,1,2,3,4,5,6,7). Numerals containing (8) or (9), such as (189_8), are invalid.
  • Place weights: Positions represent (8^0,8^1,8^2,\ldots), giving weights (1,8,64,512,\ldots).
  • Binary relationship: Because (8=2^3), exactly three binary bits correspond to one octal digit. Thus, (5_8) corresponds to (101_2).
  • Worked example: The decimal value of (725_8) is:
TEXT
725₈ = 7×8² + 2×8¹ + 5×8⁰
     = 7×64 + 2×8 + 5
     = 469₁₀
  • Maximum digit value: The largest octal digit, (7_8), equals the three-bit pattern (111_2).

B. Applications and Limitations

Octal is useful when binary information naturally divides into groups of three bits.

  • Compactness: (111101011_2) can be written more briefly as (753_8), with each octal digit replacing three bits.
  • Historical use: Octal was common on computer architectures whose word lengths were multiples of three, including some 12-bit and 24-bit systems.
  • Current use: Unix-like file permissions use octal notation; permission value (7) represents the bit pattern (111), meaning read, write, and execute.
  • Limitation: Modern systems commonly use byte-oriented units of eight bits, making hexadecimal’s four-bit grouping more convenient than octal.

V. Hexadecimal — Base 16

A. Hexadecimal

Hexadecimal is a base-(16) system that expresses binary data compactly by representing each group of four bits with one digit.

  • Digit set: Hexadecimal uses (0)–(9) and (A)–(F), where (A=10), (B=11), (C=12), (D=13), (E=14), and (F=15).
  • Place weights: Positions have weights (16^0,16^1,16^2,\ldots), equal to (1,16,256,\ldots).
  • Binary relationship: Since (16=2^4), one hexadecimal digit represents four bits; (A_{16}=10102) and (F{16}=1111_2).
  • Worked example: The value of (2AF_{16}) is:
TEXT
2AF₁₆ = 2×16² + 10×16¹ + 15×16⁰
      = 512 + 160 + 15
      = 687₁₀
  • Notation conventions: Hexadecimal may appear as (2AF_{16}), 0x2AF in many programming languages, or 2AFh in some assembly notation.

B. Applications and Limitations

Hexadecimal offers a practical balance between binary correspondence and human readability.

  • Memory representation: Byte values range from 00 to FF, because eight bits divide into two groups of four.
  • Addresses and machine code: Memory addresses and instruction bytes are often displayed in hexadecimal, such as 0x7F2A.
  • Colour notation: Web colour #FF0000 represents maximum red and zero green and blue, using two hexadecimal digits per channel.
  • Limitation: Letters used as digits can confuse beginners, and hexadecimal values must be converted before they have an intuitive decimal magnitude.

VI. Number System Conversions — Changing Representation Without Changing Value

A. Number System Conversions

Number system conversions change a numeral’s representation while preserving the quantity it denotes.

  • Base to decimal: Multiply each digit by its positional weight and add the products:
TEXT
Value₁₀ = Σ dᵢ × bⁱ
  • (d_i) is the digit at position (i).
  • (b) is the original base.
  • (i) is the positional exponent.
    • Decimal integer to another base: Repeatedly divide the integer by the target base. Record each remainder, then read the remainders from last to first.
    • Decimal fraction to another base: Repeatedly multiply the fractional part by the target base. Record each integer part in order; stop when the fraction becomes zero or the required precision is reached.
    • Binary to octal: Group bits in threes outward from the binary point, adding zeros at the outer ends when necessary.
    • Binary to hexadecimal: Group bits in fours outward from the binary point. For example, groups 1010 and 1111 correspond to (A) and (F).
    • Octal and hexadecimal conversion: Convert each octal digit to three bits or each hexadecimal digit to four bits, then regroup the binary digits for the destination base.
    • Integrated worked example: Convert (156_{10}) to binary, octal, and hexadecimal:
TEXT
156₁₀ = 10011100₂
Binary grouping:
010 011 100₂ = 234₈
1001 1100₂   = 9C₁₆

The value is unchanged: (2348=2(64)+3(8)+4=156{10}), and (9C{16}=9(16)+12=156{10}).

B. Accuracy, Validation, and Practical Significance

A conversion is reliable only when digit validity, grouping, and positional values are preserved.

  • Validity check: Every digit must be smaller than the base; (788) and (1G{16}) are invalid.
  • Reverse conversion: Converting the result back to the original base verifies the work; (9C{16}) returns to (156{10}).
  • Zero padding: Added zeros must not change place value. Binary 1111 may become 0000 1111 for hexadecimal grouping, yielding (0F_{16}).
  • Fractional precision: A conversion may not terminate. Repeating digits must be rounded or truncated to a stated number of places.
  • Computing significance: Conversions connect human-oriented decimal input, machine-oriented binary storage, and compact octal or hexadecimal displays used in programming, debugging, networking, and digital electronics.