- Published on
- Published on
KembaraXtra-Computer Science-Representing Data Digitally
1. Digital Representation of Data
3.1 Grayscale Representation
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
- 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.
- 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.
- 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.
- Another standard that handles characters in nearly all languages, including English.
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).
- 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.
- 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).
- 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.
- 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)
- Example: 011000010110001001100011
- 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.
- 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.
- Published on
- Published on
KembaraXtra-Computer Science-Number Systems
1. Introduction
1. Introduction
- Computers are digital machines that operate using 0s and 1s.
- Understanding number systems is essential to understanding how computers work with numbers.
- The number system humans commonly use.
- Uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
- Employs place-value notation
- Each position in a number represents a different power of 10 (base 10).
- Example: 275
- 5 is in the ones place (10⁰ = 1), so its value is 5 * 1 = 5.
- 7 is in the tens place (10¹ = 10), so its value is 7 * 10 = 70.
- 2 is in the hundreds place (10² = 100), so its value is 2 * 100 = 200.
- Total value: 5 + 70 + 200 = 275.
- Each place is a power of 10.
- Rightmost place: 10⁰ = 1 (ones place)
- Next place: 10¹ = 10 (tens place)
- Next place: 10² = 100 (hundreds place)
- And so on (10³ = 1000, etc.)
- Decimal uses ten symbols (0-9) because each place can represent ten different values.
- Any ten unique symbols could be used, but 0-9 is the convention.
- The number system used by computers (two symbols)
- Uses only two symbols: 0 and 1.
- Still a place-value system, but each place represents a power of 2.
- Each position is a power of 2 (base 2).
- Example: 101 (binary) which equals 5 (decimal)
- Rightmost place: 2⁰ = 1
- Next place: 2¹ = 2
- Next place: 2² = 4
- Total value: (1 * 1) + (0 * 2) + (1 * 4) = 1 + 0 + 4 = 5
- Multiply the symbol in each place by the place-value weight (power of 2) and sum the results.
- Find the largest power of 2 that is less than or equal to the decimal number.
- Subtract that power of 2 from the decimal number and repeat the process with the remainder.
- Put a 1 in the places corresponding to the powers of 2 that were used and a 0 in the other places.
- To avoid confusion, binary numbers are often written with a 0b prefix (e.g., 0b10 represents 2 in binary).
- Numbers without a prefix are assumed to be decimal.
- Published on
KembaraXtra-Computer Science- Bits and Bytes
Key Definitions
Key Definitions
- Digit: A single symbol in a decimal number (base-10).
- Bit (Binary Digit): A single symbol in a binary number (base-2). It can be either 0 or 1.
- Byte: A group of 8 bits.
- Nibble: A group of 4 bits (half a byte).
- A single bit can represent two states: 0 or 1 (off or on).
- To represent more complex information, bits are combined into sequences.
- Computers group bits into bytes (8 bits) for easier management.
- 4-bit Number: Can represent 16 unique combinations (from 0000 to 1111). Decimal values range from 0 to 15.
- Byte (8-bit): Can represent 256 unique combinations.
- Formula: The number of unique combinations for n bits is 2n.
- Example: 24 = 16, 28 = 256
- Computer engineers need to consider how many bits or bytes will be needed for storage of data.
- Example: A game with 12 levels can store the level number in 4 bits, but a game with 99 levels needs a byte.
- Published on
KembaraXtra – Computer Terms – * :
The asterisk, also called the star symbol, is widely used in various computing environments. In programming, it often means multiplication. For example, 5 * 3 equals 15. In operating systems like Windows and MS-DOS, it works as a wildcard character to replace one or more characters in a filename. For instance, *.txt would refer to all text files. In C and C++ programming, the asterisk is also used for pointer operations—it helps retrieve the actual value stored at a memory location pointed to by a pointer variable.
The asterisk, also called the star symbol, is widely used in various computing environments. In programming, it often means multiplication. For example, 5 * 3 equals 15. In operating systems like Windows and MS-DOS, it works as a wildcard character to replace one or more characters in a filename. For instance, *.txt would refer to all text files. In C and C++ programming, the asterisk is also used for pointer operations—it helps retrieve the actual value stored at a memory location pointed to by a pointer variable.
- Published on
KembaraXtra – Computer Terms – .. means:
Two dots used together in file system navigation refer to the parent directory—the folder above the current one in the directory structure. This is a common shorthand used in UNIX and MS-DOS. A single dot (.) refers to the current directory. Together, .. is essential for moving up levels in command-line interfaces.
Two dots used together in file system navigation refer to the parent directory—the folder above the current one in the directory structure. This is a common shorthand used in UNIX and MS-DOS. A single dot (.) refers to the current directory. Together, .. is essential for moving up levels in command-line interfaces.
- Published on
- Published on
KembaraXtra – Computer Terms – . means:
This symbol combination is a wildcard pattern used mainly in command-line environments like MS-DOS and Windows. It represents every possible file name and every possible extension. For example, *.* could be used to copy, move, or delete all files in a directory, regardless of their names or file types. It is especially useful when performing actions on many files at once.
This symbol combination is a wildcard pattern used mainly in command-line environments like MS-DOS and Windows. It represents every possible file name and every possible extension. For example, *.* could be used to copy, move, or delete all files in a directory, regardless of their names or file types. It is especially useful when performing actions on many files at once.
- Published on
KembaraXtra-Case Law-Software Terms Defined
I. Key Definitions:
I. Key Definitions:
- Software: Instructions that tell a computer what to do. Contrast: Hardware (physical components).
- Program: An ordered set of software instructions that accomplishes a task. Related term: Programming (writing such programs).
- Application: Often used synonymously with "program", but implies direct interaction with humans. Can consist of multiple programs. Related term: App (modern usage, connotations to be covered later).
- Code (Computer Code): Another name for a set of software instructions.
- Source Code: The text of a program as originally written by developers. Written in a higher-level programming language. Requires additional steps before execution.
- Machine Code: Software in binary machine language instructions that a CPU can directly execute.
- Machine Language: The set of instructions a specific CPU architecture understands.
- Source Code --> Machine Code: Source code, written by developers, must be converted into machine code for the CPU to execute.
- Universal Conversion: Regardless of the initial programming language or technologies used, all programs ultimately become a series of 0s and 1s representing CPU instructions.
- "It's Just Code": Even complex software, when examined at its most fundamental level, is simply a series of instructions (0s and 1s) that a CPU interprets.
- Human Language vs. Machine Language:
- Vocabulary words are like CPU instructions.
- Sentences formed from words are like programs formed from instructions. Both convey meaning.