Data Representation

What is Data Representation?

  • How different types of information (numbers, text, images, sound) are encoded and stored in a computer using binary (0s and 1s).

Components:

Numbers in Binary  
  • Binary System: Base-2 numeral system that uses two digits, 0 and 1.
  • Conversion:
    • Decimal to Binary: Divide the number by 2, record the remainder, and repeat with the quotient until you reach 0. Read the remainders in reverse order.
    • Binary to Decimal: Multiply each binary digit by 2 raised to the power of its position, starting from 0 on the right, and sum the results.
  • Example:
    • Decimal 5 to Binary: 510=1012
    • Binary 1010 to Decimal: 1×23+0×22+1×21+0×20=1010
  • Text in Binary
  • Character Encoding:
    • ASCII (American Standard Code for Information Interchange): Uses 7 or 8 bits to represent characters (e.g., 'A' is 65 in decimal or 01000001 in binary).
    • Unicode: Supports a larger set of characters with different encoding forms like UTF-8, which uses 8 to 32 bits.
  • Example:
    • The letter 'A' in ASCII: 01000001
  • Images in Binary
  • Bitmap Images:
    • Pixels: Small dots that make up an image, each pixel is represented by bits.
    • Color Depth: Number of bits used to represent the color of each pixel (e.g., 1-bit for black and white, 24-bit for true color).
  • Vector Images:
    • Description: Represent images using geometric shapes and equations, which are then converted to binary.
  • Example:
    • A 2x2 pixel black and white image:
      • 0110
      • Binary: 01101001
  • Sound in Binary
  • Analog to Digital Conversion (ADC):
    • Sampling: Measuring the amplitude of sound waves at regular intervals.
    • Bit Depth: Number of bits used to represent each sample (e.g., 16-bit, 24-bit).
    • Sampling Rate: Number of samples taken per second (e.g., 44.1 kHz).
  • Example:
    • A sound wave sampled at 44.1 kHz with a bit depth of 16 bits results in a binary representation for each sample.