TECHNOLOGY 

Published on
KembaraXtra-Computer Science-Representing Data Digitally
1. Digital Representation of Data
  • Computers store all data as bits (0s and 1s).
  • This includes:
    • Negative numbers
    • Fractional numbers
    • Text
    • Colors
    • Images
    • Audio
    • Video
2. Digital Text
  • Text is represented as a collection of alphanumeric and related symbols (characters).
  • Includes:
    • A-Z (uppercase and lowercase - distinct)
    • Punctuation marks (e.g., commas, periods)
    • Spaces
    • Digits 0-9 (as symbols, not numerical values)
  • String: a sequence of text characters (common term in programming).
  • Encoding: Translating data into a digital format.
  • Decoding: Interpreting digital data.
2.1 Representing Text with Bits
  • Around 100 characters need to be represented.
  • 6 bits: 64 unique combinations (not enough)
  • 7 bits: 128 unique combinations (enough)
  • Commonly, 8 bits (1 byte) are used to represent each character (256 unique characters possible).
  • Any scheme can be used to represent characters as bits, as long as the software knows the scheme.
  • Software designers prefer schemes that make operations easy.
2.2 ASCII
  • American Standard Code for Information Interchange.
  • Standard for representing text digitally.
  • Represents 128 characters using 7 bits (often stored as 8 bits, with a leading 0).
  • Handles English characters.
2.3 Unicode
  • Another standard that handles characters in nearly all languages, including English.
3. Digital Colors and Images
3.1 Grayscale Representation
  • Limiting colors to black, white, and shades of gray.
  • Example: Representing black, white, dark gray, and light gray (4 colors) requires 2 bits (2^2 = 4).
3.2 Representing Images
  • An image is an arrangement of colors on a two-dimensional plane.
  • Colors are arranged in a grid of single-color squares called pixels.
  • An image's dimensions are defined by its width and height in pixels.
3.3 Standard Approaches for Colors and Images
  • Grayscale: 8 bits per pixel allows for 256 shades of gray (0 = black, 255 = white).
  • RGB: Uses three 8-bit numbers to represent the intensity of Red, Green, and Blue. This means 24 bits represent the overall color.
    • Additive color model: colors composed of a mix of red, green, and blue light.
    • Each component color can vary from 0 (darker shade) to 255 (brighter shade).
3.4 Image Formats
  • Bitmap: Stores RGB color data for each individual pixel (simplistic).
  • JPEG and PNG: Use compression techniques to reduce the number of bytes to store an image.
4. Interpreting Binary Data
  • A single binary value can have different meanings depending on the context.
    • Example: 011000010110001001100011
      • ASCII text string: "abc"
      • 24-bit RGB color: a shade of gray
      • Positive integer: 6,382,179 (decimal)
  • The interpretation depends on the software used to process the data (text editor, image viewer, calculator, etc.).
  • Programs are written to expect data in a particular format.
5. General Principles
  • Any type of data can be represented digitally (numbers, text, colors, images, audio, video, etc.).
  • The digital representation may not be a perfect replica, but is often sufficient.
  • Representing data as 0s and 1s is useful because a device that works with binary data can be adapted to deal with any kind of data through software.
Picture
0 Comments