COMP101: Introduction to Computing - Number Systems

Course Overview and Institutional Integration

  • Course Information:

    • Course Code & Title: COMP101: Introduction to Computing
    • Module: Module 2: Number System (Weeks 4 and 5)
    • Institution: Kolehiyo ng Lungsod ng Dasmariñas (KLD)
    • Academic Department: Institute of Foundational Studies
    • Address: Brgy. Burol Main, City of Dasmariñas, Cavite, Philippines 4114
    • Website: www.kld.edu.ph
  • Course Outcomes & Intended Learning Outcomes:

    • Course Outcome (CO4): Determine and transform number system conversions.
    • Intended Learning Outcome (LO1): Learn the different types of number systems.
  • SDG and KLD REGAL100 Integration:

    • SDG 4: Quality Education
    • SDG 8: Decent Work and Economic Growth
    • SDG 9: Industry, Innovation, and Infrastructure
    • REGAL 100: Information Literacy Program

Introduction to Number Systems

  • Definition and Context:

    • A number system is a structured way to represent or express numbers.
    • Numbers represented in any specific number system category can be converted into any other system.
    • Standard mathematical number systems include whole numbers and real numbers, but computer architecture utilizes specialized digital number systems.
  • Rationale for Digital Systems:

    • In digital hardware, instructions and data are transmitted using electric signals.
    • Signal variations are controlled by varying signal voltage.
    • Implementing ten distinct voltage levels to process the decimal system directly in digital equipment is technically complex and unreliable.
    • Consequently, digital systems rely on alternative positional number systems that are simpler to implement using binary voltage logic.
  • Four Core Computer Number Systems:

    • Decimal Number System
    • Binary Number System
    • Octal Number System
    • Hexadecimal Number System

Characteristics of Core Number Systems

  • Decimal Number System:

    • Base / Radix: 1010
    • Digits Used: 1010 digits (0,1,2,3,4,5,6,7,8,90, 1, 2, 3, 4, 5, 6, 7, 8, 9)
    • Positional weight increases to the left of the decimal point, representing units, tens, hundreds, thousands, and so on.
    • Every position corresponds to an increasing power of the base 1010.
    • Digit values are strictly position-dependent. For example, considering the value of the digit 77 across three different numbers:
    • In 734734, the value of 77 is 77 hundreds = 700700 = 7×1007 \times 100 = 7×1027 \times 10^2
    • In 971971, the value of 77 is 77 tens = 7070 = 7×107 \times 10 = 7×1017 \times 10^1
    • In 207207, the value of 77 is 77 units = 77 = 7×17 \times 1 = 7×1007 \times 10^0
  • Binary Number System:

    • Base / Radix: 22
    • Digits Used: 22 digits (00 and 11)
    • Represents the hardware switch states: off (00) and on (11).
    • Bit Definition: A single binary digit is called a bit.
    • Positional values are represented by increasing powers of 22.
    • Key Terms:
    • Least Significant Bit (LSB): The rightmost digit in a binary number.
    • Most Significant Bit (MSB): The leftmost digit in a binary number.
    • Decimal Evaluation Example:
    • 110102=1×24+1×23+0×22+1×21+0×2011010_2 = 1 \times 2^4 + 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 0 \times 2^0
    • 110102=16+8+0+2+0=261011010_2 = 16 + 8 + 0 + 2 + 0 = 26_{10}
  • Computer Memory Capacity Conversion Table:

    • 1 byte (B)=8 bits1\text{ byte (B)} = 8\text{ bits}
    • 1 Kilobyte (KB)=1024 bytes1\text{ Kilobyte (KB)} = 1024\text{ bytes}
    • 1 Megabyte (MB)=1024 KB1\text{ Megabyte (MB)} = 1024\text{ KB}
    • 1 Gigabyte (GB)=1024 MB1\text{ Gigabyte (GB)} = 1024\text{ MB}
    • 1 Terabyte (TB)=1024 GB1\text{ Terabyte (TB)} = 1024\text{ GB}
    • 1 Exabyte (EB)=1024 PB1\text{ Exabyte (EB)} = 1024\text{ PB}
    • 1 Zettabyte=1024 EB1\text{ Zettabyte} = 1024\text{ EB}
    • 1 Yottabyte (YB)=1024 ZB1\text{ Yottabyte (YB)} = 1024\text{ ZB}
  • Octal Number System:

    • Base / Radix: 88
    • Digits Used: 88 digits (0,1,2,3,4,5,6,70, 1, 2, 3, 4, 5, 6, 7)
    • Widely used in computer applications and electronic systems.
  • Hexadecimal Number System:

    • Base / Radix: 1616
    • Digits/Symbols Used: 1616 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F0, 1, 2, 3, 4, 5, 6, 7, 8, 9, \text{A}, \text{B}, \text{C}, \text{D}, \text{E}, \text{F})
    • Each position represents a power of 1616.
    • Because the base exceeds 1010, standard numeric digits are supplemented by alphabetic letters:
    • A=10\text{A} = 10
    • B=11\text{B} = 11
    • C=12\text{C} = 12
    • D=13\text{D} = 13
    • E=14\text{E} = 14
    • F=15\text{F} = 15
    • The inclusion of letters A\text{A} through F\text{F} is purely conventional.

Decimal Conversion Methods

  • Decimal to Binary Conversion:

    • Procedure: Repeatedly divide the decimal integer by 22, record the remainder at each step, and continue until the quotient becomes 00. Write the remainders in backward order (from bottom to top, LSB to MSB).
    • Example: Convert 251025_{10} to binary.
    • 25/2=1225 / 2 = 12 with remainder 11
    • 12/2=612 / 2 = 6 with remainder 00
    • 6/2=36 / 2 = 3 with remainder 00
    • 3/2=13 / 2 = 1 with remainder 11
    • 1/2=01 / 2 = 0 with remainder 11
    • Reading remainders backward yields: 2510=11001225_{10} = 11001_2
  • Decimal to Octal Conversion:

    • Procedure: Repeatedly divide the decimal integer by 88, record the remainder at each step, and continue until the quotient is 00. Write remainders in backward order.
    • Example: Convert 12810128_{10} to octal.
    • 128/8=16128 / 8 = 16 with remainder 00
    • 16/8=216 / 8 = 2 with remainder 00
    • 2/8=02 / 8 = 0 with remainder 22
    • Reading remainders backward yields: 12810=2008128_{10} = 200_8
  • Octal to Decimal Conversion:

    • Procedure: Multiply each digit of the octal number by decreasing powers of base 88, starting from MSB to LSB, and sum all products together.
    • Example 1: Convert 22822_8 to decimal.
    • 228=2×81+2×80=16+2=181022_8 = 2 \times 8^1 + 2 \times 8^0 = 16 + 2 = 18_{10}
    • Example 2: Convert 2158215_8 to decimal.
    • 2158=2×82+1×81+5×80215_8 = 2 \times 8^2 + 1 \times 8^1 + 5 \times 8^0
    • 2158=2×64+1×8+5×1=128+8+5=14110215_8 = 2 \times 64 + 1 \times 8 + 5 \times 1 = 128 + 8 + 5 = 141_{10}
  • Decimal to Hexadecimal Conversion:

    • Procedure: Repeatedly divide the decimal integer by 1616, record the remainder, and write the remainders backward when quotient reaches 0$.\n * **Example:** Convert 128_{10} to hexadecimal.\n * 128 / 16 = 8withremainderwith remainder0\n * 8 / 16 = 0withremainderwith remainder8\n * Reading remainders backward yields: 128_{10} = 80_{16}\n\n* **Hexadecimal to Decimal Conversion:**\n * **Procedure:** Multiply each hexadecimal digit by powers of 16startingfromtheunitsplace(starting from the units place (16^0) at the LSB and increase powers moving left to the MSB, then sum the terms.\n * **Example:** Convert 7 ext{CF}{16} to decimal.\n * Hexadecimal symbol values: 7 = 7,, ext{C} = 12,, ext{F} = 15\n * 7 ext{CF}{16} = (7 imes 16^2) + (12 imes 16^1) + (15 imes 16^0)\n * 7 ext{CF}{16} = (7 imes 256) + (12 imes 16) + (15 imes 1)\n * 7 ext{CF}{16} = 1792 + 192 + 15 = 1999_{10}\n\n# Binary Conversion Methods\n\n* **Binary to Decimal Conversion:**\n * **Procedure:** Multiply each binary digit starting from MSB to LSB by decreasing powers of the base 2, then sum all terms.\n * **Example:** Convert 1101_2 to decimal.\n * 1101_2 = 1 imes 2^3 + 1 imes 2^2 + 0 imes 2^1 + 1 imes 2^0\n * 1101_2 = 8 + 4 + 0 + 1 = 13_{10}\n\n* **Binary to Octal Conversion Methods:**\n * Direct one-step manual conversion is not typically used; two main systematic methods exist.\n * **Method 1 (Indirect via Decimal):**\n * Step 1: Identify the binary number.\n * Step 2: Convert binary to decimal by multiplying each digit by 2^{n-1}(where(wheren is digit position from the right).\n * Step 3: Compute the equivalent decimal sum.\n * Step 4: Divide the resulting decimal number by 8$.
    • Step 5: Note the remainder.
    • Step 6: Repeat division with the quotient until quotient equals 0$.\n * Step 7: Write the remainders in reverse order.\n * Step 8: The resulting digits form the target octal number.\n * **Example:** Convert 1011101_2 to octal.\n * Binary to Decimal: 1011101_2 = (1 imes 2^6) + (0 imes 2^5) + (1 imes 2^4) + (1 imes 2^3) + (1 imes 2^2) + (0 imes 2^1) + (1 imes 2^0)\n * 1011101_2 = 64 + 0 + 16 + 8 + 4 + 0 + 1 = 93_{10}\n * Decimal to Octal (Divide 93byby8):\n * 93 / 8 = 11remainderremainder5\n * 11 / 8 = 1remainderremainder3\n * 1 / 8 = 0remainderremainder1\n * Collecting remainders in reverse order gives: 135_8\n * Therefore, 1011101_2 = 135_8\n * **Method 2 (Direct Grouping):**\n * Step 1: Identify the binary number (base 2digitsdigits0oror1).\n * Step 2: Group binary digits into sets of three starting from the right side.\n * Step 3: Add leading zeros to the left if the leftmost group contains fewer than three digits.\n * Step 4: Map each 3-bit group to its octal equivalent digit.\n * Step 5: Concatenate the resulting octal digits.\n * **Example:** Convert 01110101_2 to octal.\n * Grouping into 3-bit sets: 001 / 110 / 101\n * Converting groups: 001_2 = 1,,110_2 = 6,,101_2 = 5\n * Output octal value: 165_8\n\n# Octal to Binary Conversion\n\n* **Procedural Steps (Two-Step Process):**\n * **Step 1: Octal to Decimal Conversion**\n * Count the total number of digits (n).\n * Multiply each digit in the n^ ext{th}positionfromtherightbyposition from the right by8^{n-1}.\n * If a fractional component exists, multiply fractional digits in the m^ ext{th}positionafterthedecimalpointbyposition after the decimal point by8^{-m}.\n * Sum all products to obtain the equivalent decimal number.\n * **Step 2: Decimal to Binary Conversion**\n * Divide the resulting decimal number by 2$.
    • Note down the remainder.
    • Continue dividing the quotient by 22 until the quotient reaches 0$.\n * Write remainders in reverse order to produce the equivalent binary number.\n\n* **Demonstration Example:** Convert 41_8 to binary.\n * Step 1 (Octal to Decimal):\n * 41_8 = (4 imes 8^1) + (1 imes 8^0) = 4 imes 8 + 1 imes 1 = 32 + 1 = 33_{10}\n * Step 2 (Decimal to Binary):\n * 33 / 2 = 16remainderremainder1\n * 16 / 2 = 8remainderremainder0\n * 8 / 2 = 4remainderremainder0\n * 4 / 2 = 2remainderremainder0\n * 2 / 2 = 1remainderremainder0\n * 1 / 2 = 0remainderremainder1\n * Writing remainders backward yields: 100001_2\n * Therefore, 41_8 = 100001_2\n\n# Binary to Hexadecimal Conversion\n\n* **Purpose:** Provides a compact way to group and represent large binary strings.\n\n* **Indirect Method (Binary to Decimal to Hexadecimal):**\n * **Example:** Convert 1101010_2 to hexadecimal.\n * Convert Binary to Decimal:\n * 1101010_2 = 1 imes 2^6 + 1 imes 2^5 + 0 imes 2^4 + 1 imes 2^3 + 0 imes 2^2 + 1 imes 2^1 + 0 imes 2^0\n * 1101010_2 = 64 + 32 + 0 + 8 + 0 + 2 + 0 = 106_{10}\n * Convert Decimal to Hexadecimal:\n * 106_{10} = 6 imes 16^1 + 10 imes 16^0 = 6 ext{A}{16}\n * Answer: 6 ext{A}{16}\n\n* **Direct Grouping Method:**\n * Because base 16consistsofconsists of16symbols(symbols (0-9andand ext{A}- ext{F}),everysinglehexadecimaldigitmapsdirectlytoaunique4−bitbinarysequence(), every single hexadecimal digit maps directly to a unique 4-bit binary sequence (2^4 = 16).\n * **Algorithm Steps:**\n * Group binary digits into sets of four.\n * For integer parts, start grouping from right to left.\n * For fractional parts, start grouping from left to right.\n * Pad with leading 0sonthefarleft(MSB)forintegersortrailings on the far left (MSB) for integers or trailing0s on the far right (LSB) for fractions to complete any incomplete 4-bit set.\n * Replace each 4-bit set with its corresponding hexadecimal digit.\n * **Example 1 (Integer Number):** Convert 1010101101001_2 to hexadecimal.\n * Grouping from right: 1 imes 0101 imes 0110 imes 1001\n * Add leading zeros to complete 4-bit groups: 0001 imes 0101 imes 0110 imes 1001\n * Map each group: 0001_2 = 1,,0101_2 = 5,,0110_2 = 6,,1001_2 = 9\n * Result: 1569_{16}\n * **Example 2 (Fractional Number):** Convert 001100101.110111_2 to hexadecimal.\n * Integer grouping (right to left from point): 001100101 ightarrow 0 imes 0110 imes 0101 ightarrow 0110 imes 0101 = 6 imes 5\n * Fractional grouping (left to right from point): .110111 ightarrow .1101 imes 1100 = ext{D} imes ext{C}\n * Result: 65. ext{DC}_{16}\n\n# Hexadecimal to Binary Conversion\n\n* **Indirect Conversion Steps (Hexadecimal to Decimal to Binary):**\n * Step 1: Take the given hexadecimal number.\n * Step 2: Determine the total number of digits (n).\n * Step 3: Multiply each digit by 16^{n-1}basedonitspositionalindexbased on its positional indexn from the right.\n * Step 4: Sum all multiplied products together.\n * Step 5: Obtain the equivalent decimal integer.\n * Step 6: Divide the decimal number by 2$.
    • Step 7: Record the remainder.
    • Step 8: Repeat division with the quotient until quotient equals 0$.\n * Step 9: Write remainders in reverse order.\n * Step 10: Output the derived binary sequence.\n\n# Inter-System Conversions (Octal and Hexadecimal)\n\n* **Octal to Hexadecimal Conversion Methods:**\n * Direct single-step mapping between octal and hexadecimal is unavailable; two indirect pathways are applied.\n * **Method A (Via Binary Representation):**\n * Step 1: Express every individual octal digit as a 3-bit binary pattern.\n * Step 2: Regroup the continuous binary pattern into 4-bit groups (from right to left).\n * Step 3: Convert each 4-bit binary group into its corresponding hexadecimal digit.\n * Reference values: 5_8 = 101_2,,6_8 = 110_2\n * **Example:** Convert 56_8 to hexadecimal.\n * Step 1: Convert 56_8tobinary:to binary:5 ightarrow 101,,6 ightarrow 110 ightarrow 101110_2\n * Step 2: Regroup into 4-bit sets from right: 10 imes 1110 ightarrow 0010 imes 1110\n * Step 3: Map to hex: 0010_2 = 2,,1110_2 = 14 = ext{E}\n * Answer: 2 ext{E}_{16}\n * **Method B (Via Decimal Representation):**\n * Step 1: Convert octal to decimal.\n * Step 2: Convert decimal to hexadecimal via repeated division by 16$.
    • Example: Convert 56856_8 to hexadecimal.
      • Step 1 (Octal to Decimal): 5×81+6×80=40+6=46105 \times 8^1 + 6 \times 8^0 = 40 + 6 = 46_{10}
      • Step 2 (Decimal to Hexadecimal):
      • 46/16=246 / 16 = 2 remainder 1414 (E\text{E})
      • 2/16=02 / 16 = 0 remainder 22
      • Reading remainders backward yields: 2E162\text{E}_{16}
  • Hexadecimal to Octal Conversion:

    • Procedure: Cannot be converted directly. Convert the hexadecimal number to its equivalent decimal number, then convert the decimal number to octal.
    • Step-by-Step Algorithm:
    • Step 1: Take the hexadecimal input and count its digits.
    • Step 2: Multiply each digit in position nn from the right by 16n−116^{n-1}.
    • Step 3: Sum all terms to compute the equivalent decimal number.
    • Step 4: Divide the resulting decimal number by 8$.\n * Step 5: Note down the remainder.\n * Step 6: Repeat division with the quotient until quotient equals 0$.
    • Step 7: Write all remainders in reverse order.
    • Step 8: The resulting sequence is the equivalent octal number.