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) .
OFF: Represented by the binary digit (bit) .
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 or .
Byte:
A group consisting of 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 represents the capital letter "T".
A byte can also represent the letter "E", the symbol "", or the number "".
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:
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.
Transmission: The scan code for the letter "T" is transmitted to the computer's electronic circuitry.
Encoding and Storage: The electronic circuitry converts the scan code into its ASCII binary code, which for "T" is . This binary representation is then stored in memory for processing.
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 ( or ). | A larger unit consisting of bits. |
Capacity | Represents one of two states. | Stores a single character or can represent up to 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: .
Binary (Base 2):
The numbering system that represents all values using only two symbols: and .
Computers use binary to represent numbers and perform all mathematical computations.
Hexadecimal (Base 16):
A system that uses sixteen different symbols: .
Decimal to Binary Conversion: Division-Remainder Method
To convert a decimal number to binary (Base to Base ), divide the decimal number by and track the remainder until the quotient reached is . Read the remainders from the bottom up.
Example 1: Convert to binary:
remainder
remainder
remainder
remainder
remainder
Result:
Example 2: Convert to binary:
remainder
remainder
remainder
remainder
remainder
remainder
Result:
Binary to Decimal Conversion: Multiply-Power of Base Method
To convert a binary number to decimal (Base to Base ), multiply each bit by its corresponding power of the base () and sum the results.
Example 1: Convert to decimal:
Step 1 (Bits): , , , ,
Step 2 (Powers): , , , ,
Step 3 (Values): , , , ,
Step 4 (Products): , , , ,
Step 5 (Sum):
Example 2: Convert to decimal:
Step 1 (Bits): , , , ,
Step 2 (Powers): , , , ,
Step 3 (Values): , , , ,
Step 4 (Products): , , , ,
Step 5 (Sum):
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 ).
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 is long and easily misread. In hexadecimal, it is simply .
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 : Use the Multiply–Powers of Base Method or the Place Value Method.
To Base : Use the Simplify Method (group bits into Hex digit) or convert via Decimal.
From Base 10 (Decimal):
To Base : Use the Division–Remainder Method (divide by ).
To Base : Use the Division–Remainder Method (divide by ).
From Base 16 (Hexadecimal):
To Base : Use the Simplify Method ( Hex digit becomes bits) or convert via Decimal.
To Base : Use the Multiply–Powers of Base Method (multiply by powers of ).