1 Data Representation

Computer Architecture · Unit 1 · 4 hrs

Data Representation

Exam-focused notes for Data Representation (Computer Architecture, CSC213): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.

Data Representation in short

This chapter looks at how a computer represents numbers, text and codes at the bit level, and at the complements, fixed and floating point layouts, and overflow checks that let simple adder hardware do subtraction and handle signed values. Computer architecture denotes the attributes of a system visible to a programmer (instruction set, data representation, addressing techniques), while computer organization denotes how those attributes are realized in hardware (control signals, buses, memory technology); both views of the same machine recur throughout this subject.

Data Representation: notes

Data Representation: Binary, BCD, Complements, Fixed and Floating Point, Overflow

A digital computer processes data held as discrete values, conventionally the two logic levels 0 and 1, while an analog computer processes continuously varying signals; a hybrid computer combines both. A bit is a single binary digit, a byte is a group of 8 bits, a nibble is half a byte (4 bits), and a word is the natural unit of data a processor works with, commonly 16, 32 or 64 bits wide. A number system is a set of symbols used to represent values, built on a base (radix): binary (2), octal (8), decimal (10) and hexadecimal (16) are the systems used throughout this subject. A decimal integer converts to binary by repeated division by 2, reading the remainders bottom to top; $25_{10}$ divides down as $25\to12,r1\to6,r0\to3,r0\to1,r1\to0,r1$, giving $25_{10}=11001_2$, checked by $16+8+1=25$.

Binary Coded Decimal (BCD) encodes each decimal digit separately as its own 4-bit pattern (the 8421 code) rather than converting the whole number to pure binary; the patterns 1010-1111 are never used. For example $12_{10}$ is encoded digit by digit as $1\to0001$ and $2\to0010$, giving the BCD pattern $00010010$, different from the pure binary equivalent $1100_2$. Alphanumeric representation assigns a binary code to letters, digits and symbols; the most common scheme is ASCII, a 7-bit code (extendable to 8 bits) supporting 128 (or 256) characters, in which the letter A is assigned the value 65, so its ASCII code is $1000001_2$.

Subtraction is expensive to build directly in hardware, so computers perform it as addition using complements. For a number $N$ with $n$ digits in radix $r$, the $r$'s complement is $r^n-N$, and the $(r-1)$'s complement is $r^n-N-1$, obtained by taking the $r$'s complement and subtracting 1. The 10's and 9's complements of $(512)_{10}$, with $r=10$, $n=3$, are $$ \begin{aligned} r\text{'s complement} &= 10^3 - 512 = 488 \ (r-1)\text{'s complement} &= 488 - 1 = 487 \end{aligned} $$

What this unit covers

  • Data Representation: Binary Representation, BCD, Alphanumeric Representation, Complements, Fixed Point representation, Representing Negative Numbers, Floating Point Representation, Arithmetic with Complements, Overflow, Detecting Overflow
  • Other Binary Codes: Gray Code, self Complementing Code, Weighted Code, Excess-3 Code, EBCDIC
  • Error Detection Codes: Parity Bit, Odd Parity, Even parity, Parity Generator & Checker

Error Detection Codes

2081 · 5 marks

How parity bit is generated in even parity? Demonstrate with suitable table and circuit diagram. [5]

Parity is an extra bit added with the original message to detect errors during data transmission. In even parity, we count the number of 1's in the binary digit: - If the count of 1's is even → parity bit = 0 - If the count of 1's is odd → parity bit = 1 This ensures that the total number of 1's ...

Open this answer on its own page →

2080 · 5 marks

What do you mean by error correction codes? Explain any one of error correction technique. [5]

Show solved answer

Error Correction Codes

Definition

An error correction code is a binary code that not only detects errors that occur during data transmission but also corrects those errors automatically without requiring retransmission. Unlike error detection codes (such as parity bits) which can only indicate the presence of an error, error correction codes can identify the exact location of the erroneous bit and fix it.


Hamming Code (Error Correction Technique)

Hamming Code is the most widely used error correction technique, developed by R.W. Hamming. It adds redundant bits (called parity bits) at specific positions to detect and correct single-bit errors.


Key Rules for Hamming Code

  • Parity bits are placed at positions that are powers of 2: position 1, 2, 4, 8, 16, ...
  • Each parity bit checks specific bit positions in the codeword.
  • Data bits occupy the remaining positions.

Formula for Number of Parity Bits

If the data has m bits, the number of parity bits r must satisfy:

2^r >= m + r + 1

Worked Example

Encode the data bits: 1011

Step 1: Determine number of parity bits

  • m = 4 (data bits)
  • Try r = 3: 2^3 = 8 >= 4 + 3 + 1 = 8 ✓
  • So we need 3 parity bits

Step 2: Total bits = m + r = 4 + 3 = 7 bits

Step 3: Assign positions

Position1 (P1)2 (P2)3 (D1)4 (P3)5 (D2)6 (D3)7 (D4)
BitP1P21P3011

Data bits 1, 0, 1, 1 are placed at positions 3, 5, 6, 7 respectively.

Step 4: Calculate parity bits (using even parity)

  • P1 (position 1): checks positions 1, 3, 5, 7

    • Bits: P1, 1, 0, 1 → count of 1s = 2 (even) → P1 = 0
  • P2 (position 2): checks positions 2, 3, 6, 7

    • Bits: P2, 1, 1, 1 → count of 1s = 3 (odd) → P2 = 1
  • P3 (position 4): checks positions 4, 5, 6, 7

    • Bits: P3, 0, 1, 1 → count of 1s = 2 (even) → P3 = 0

Step 5: Final Hamming Codeword

Position1234567
Bit0110011

Transmitted codeword: 0110011


Error Detection and Correction

At the receiver, parity checks are recalculated. If an error occurs (say bit 5 flips from 0 to 1):

  • The parity checks that fail are noted.
  • Their position numbers are added to give the position of the erroneous bit.
  • That bit is then flipped to correct the error.

Advantages of Hamming Code

  • Corrects all single-bit errors
  • Detects double-bit errors (with extended Hamming code)
  • Efficient and widely used in memory systems (ECC RAM)
Open this answer on its own page →

2075.1 · 6 marks

Explain the error detection codes with example. [6]

An error detection code is a binary code that detects digital errors during data transmission. The detected errors cannot be corrected but their presence is indicated to the receiver. --- Parity is an extra bit added to the original message to detect errors during data transmission. This techniqu...

Open this answer on its own page →

Data Representation

2080 · 5 marks

What is arithmetic overflow? How can it be detected? [5]

Arithmetic overflow occurs when the result of an arithmetic operation on two n-bit binary numbers produces a result that requires more bits than the available n bits can hold. In other words, while adding two n-bit binary numbers, the result may be a number with n+1 bits -- this situation is call...

Open this answer on its own page →

2079 · 5 marks

What are different methods for representing signed numbers? Represent (-71) in those formats. [5]

  • Number to represent: $-71$ - Assumed word size: 8 bits (standard for such problems) --- There are three standard methods: 1. Signed Magnitude Representation 2. 1's Complement Representation 3. 2's Complement Representation In each method, the MSB is the sign bit: 0 = positive, 1 = negative. ---...
Open this answer on its own page →