Data Representation and Number Systems in Computer Science

Fundamentals of Computer Data Representation

  • Electronic State Representation: Computers recognize data and instructions through electrical states. These are represented as two discrete states:

    • ON: Represented by the binary digit (bit) 11.

    • OFF: Represented by the binary digit (bit) 00.

  • Data Types: Computers use this binary system to represent various forms of information, including numbers, words, pictures, music, and video.

Defining Bit and Byte

  • Bit (Binary Digit):

    • The smallest unit of data that a computer is capable of processing.

    • It consists of a single value: either 00 or 11.

  • Byte:

    • A group consisting of 88 bits (1 byte=8 bits1\text{ byte} = 8\text{ bits}).

    • A byte represents a single character in a computer or mobile device, such as a digit, a letter, a punctuation mark, or any other symbol.

    • Examples:

      • The binary string 0101010001010100 represents the capital letter "T".

      • A byte can also represent the letter "E", the symbol "×\times", or the number "66".

Conversion Process: From Keyboard to Output

Converting a character (e.g., the capital letter "T") into binary form and back involves a specific four-step process:

  1. Input Initiation: The user presses the capital letter "T" (using the SHIFT + T keys) on the keyboard. This action generates a unique code known as a scan code.

  2. Transmission: The scan code for the letter "T" is transmitted to the computer's electronic circuitry.

  3. Encoding and Storage: The electronic circuitry converts the scan code into its ASCII binary code, which for "T" is 0101010001010100. This binary representation is then stored in memory for processing.

  4. Output Rendering: Once processing is complete, the computer converts the binary code back into an image of the letter "T" and displays it on the output device (e.g., the monitor).

Distinct Differences Between Bit and Byte

Feature

Bit

Byte

Size/Definition

The smallest unit of data (00 or 11).

A larger unit consisting of 88 bits.

Capacity

Represents one of two states.

Stores a single character or can represent up to 256256 individual characters.

Usage/Measurement

Used to measure the speed of data transfer.

Used to measure storage capacity.

Classification of Number Systems

There are three primary numbering systems relevant to computer systems and data representation:

  • Decimal (Base 10):

    • The standard system used in daily human life.

    • It utilizes ten unique symbols: 0,1,2,3,4,5,6,7,8,90, 1, 2, 3, 4, 5, 6, 7, 8, 9.

  • Binary (Base 2):

    • The numbering system that represents all values using only two symbols: 00 and 11.

    • Computers use binary to represent numbers and perform all mathematical computations.

  • Hexadecimal (Base 16):

    • A system that uses sixteen different 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, A, B, C, D, E, F.

Decimal to Binary Conversion: Division-Remainder Method

To convert a decimal number to binary (Base 1010 to Base 22), divide the decimal number by 22 and track the remainder until the quotient reached is 00. Read the remainders from the bottom up.

  • Example 1: Convert 231023_{10} to binary:

    • 23/2=1123 / 2 = 11 remainder 11

    • 11/2=511 / 2 = 5 remainder 11

    • 5/2=25 / 2 = 2 remainder 11

    • 2/2=12 / 2 = 1 remainder 00

    • 1/2=01 / 2 = 0 remainder 11

    • Result: 10111210111_{2}

  • Example 2: Convert 561056_{10} to binary:

    • 56/2=2856 / 2 = 28 remainder 00

    • 28/2=1428 / 2 = 14 remainder 00

    • 14/2=714 / 2 = 7 remainder 00

    • 7/2=37 / 2 = 3 remainder 11

    • 3/2=13 / 2 = 1 remainder 11

    • 1/2=01 / 2 = 0 remainder 11

    • Result: 1110002111000_{2}

Binary to Decimal Conversion: Multiply-Power of Base Method

To convert a binary number to decimal (Base 22 to Base 1010), multiply each bit by its corresponding power of the base (22) and sum the results.

  • Example 1: Convert 11101211101_{2} to decimal:

    • Step 1 (Bits): 11, 11, 11, 00, 11

    • Step 2 (Powers): 242^4, 232^3, 222^2, 212^1, 202^0

    • Step 3 (Values): 1616, 88, 44, 22, 11

    • Step 4 (Products): (1×16)(1 \times 16), (1×8)(1 \times 8), (1×4)(1 \times 4), (0×2)(0 \times 2), (1×1)(1 \times 1)

    • Step 5 (Sum): 16+8+4+0+1=291016 + 8 + 4 + 0 + 1 = 29_{10}

  • Example 2: Convert 10111210111_{2} to decimal:

    • Step 1 (Bits): 11, 00, 11, 11, 11

    • Step 2 (Powers): 242^4, 232^3, 222^2, 212^1, 202^0

    • Step 3 (Values): 1616, 88, 44, 22, 11

    • Step 4 (Products): (1×16)(1 \times 16), (0×8)(0 \times 8), (1×4)(1 \times 4), (1×2)(1 \times 2), (1×1)(1 \times 1)

    • Step 5 (Sum): 16+0+4+2+1=231016 + 0 + 4 + 2 + 1 = 23_{10}

Rationale for Binary and Hexadecimal Notation

Why Binary Notation is Used
  • Machine Understanding: Binary is the native machine language of computers, allowing for faster execution.

  • Simplicity: It provides two clearly distinct states (True/False or 0/10/1).

  • Hardware Design: Circuit design is simplified because the system uses fewer arithmetic rules.

  • Efficiency: It requires a smaller amount of space in terms of memory utilization.

Why Hexadecimal Notation is Used
  • Readability: It represents long binary values in a more compact and human-readable form.

  • Compactness: As a shorthand method, hexadecimal groups four binary digits into a single symbol.

    • Example: The binary string 110101000100111021101010001001110_{2} is long and easily misread. In hexadecimal, it is simply D44E16D44E_{16}.

  • Efficiency of Conversion: Converting between binary and hexadecimal is extremely efficient because exactly four bits represent one hexadecimal digit.

Summary of Number System Conversions

  • From Base 2 (Binary):

    • To Base 1010: Use the Multiply–Powers of Base Method or the Place Value Method.

    • To Base 1616: Use the Simplify Method (group 44 bits into 11 Hex digit) or convert via Decimal.

  • From Base 10 (Decimal):

    • To Base 22: Use the Division–Remainder Method (divide by 22).

    • To Base 1616: Use the Division–Remainder Method (divide by 1616).

  • From Base 16 (Hexadecimal):

    • To Base 22: Use the Simplify Method (11 Hex digit becomes 44 bits) or convert via Decimal.

    • To Base 1010: Use the Multiply–Powers of Base Method (multiply by powers of 1616).