TECHNOLOGY 

Published on

KembaraXtra-Computer Science - Binary Logic

Core Concept

  • Computers use binary logic to process data. This system uses true (1) or false (0) values to represent logical statements.

Why Binary for Logic?

  • Logic deals with true/false statements.
  • A bit has two states: 1 or 0.
  • Therefore, a bit can represent a true/false logical state.

Truth Tables

  • Definition: A table showing all possible combinations of input conditions and their logical outcomes.
  • Used to express how components behave given certain inputs.

Example: Rectangle Logic

Statement: If a shape has four sides AND four right angles, then it's a rectangle.

Four Sides Four Right Angles Rectangle
False False False
False True False
True False False
True True True

Generic AND Truth Table

A B Output
False False False
False True False
True False False
True True True

AND Truth Table (Binary)

A B Output
0 0 0
0 1 0
1 0 0
1 1 1

OR Truth Table (Binary)

A B Output
0 0 0
0 1 1
1 0 1
1 1 1

Combining AND and OR

Example: (A AND B) OR C

A B C Output
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1

Other Logical Operators

NOT

  • Reverses the input.
A Output
0 1
1 0

NAND (NOT AND)

  • Reverse of AND. Output is false only when both inputs are true.
A B Output
0 0 1
0 1 1
1 0 1
1 1 0

NOR (NOT OR)

  • Reverse of OR. Output is true only when both inputs are false.
A B Output
0 0 1
0 1 0
1 0 0
1 1 0

XOR (Exclusive OR)

  • Output is true only if one of the inputs is true, but not both.
A B Output
0 0 0
0 1 1
1 0 1
1 1 0

Boolean Algebra

  • Study of logical functions with true/false variables.
  • Developed by George Boole.
  • Fundamental to digital electronics and computers.
Picture
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
Published on

KembaraXtra - Computer Science - Hexadecimal

Introduction

  • Hexadecimal (or hex) is a base-16 number system.
  • It's used to represent binary numbers in a more human-readable format.

Understanding Hexadecimal

  • Place Value: Each position represents a power of 16 (ones, sixteens, 256s, 4096s, etc.).
  • Symbols: Uses 16 symbols: 0-9 and A-F.
  • A = 10, B = 11, C = 12, D = 13, E = 14, F = 15
  • Prefix: 0x is commonly used to indicate a hexadecimal number (e.g., 0x1A).
  • Counting: After 0xF comes 0x10 (decimal 16), then 0x11, 0x12, etc.

Table 1-5: Hexadecimal Symbols

Hexadecimal Decimal Binary (4-bit)
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111

Converting Hexadecimal to Decimal

Multiply the decimal equivalent of each hex digit by its corresponding power of 16.

Example: 0x1A5

  • 5 is in the ones place: 5 * 1 = 5
  • A (10) is in the sixteens place: 10 * 16 = 160
  • 1 is in the 256s place: 1 * 256 = 256
  • Total: 5 + 160 + 256 = 421

Why Use Hexadecimal?

  • Readability: Easier to read and write than long binary sequences.
  • Conversion to Binary: Straightforward conversion between hexadecimal and binary.

Relationship Between Hexadecimal and Binary

  • Each hexadecimal symbol represents 4 bits (a nibble).
  • A byte (8 bits) can be represented by two hexadecimal symbols.
  • A 16-bit number can be represented by four hex symbols.
  • A 32-bit number can be represented by eight hex symbols.

Converting Binary to Hexadecimal

  1. Group the binary number into groups of 4 bits, starting from the right.
  2. Convert each group of 4 bits into its corresponding hexadecimal symbol.

Converting Hexadecimal to Binary

  1. Convert each hexadecimal digit to its 4-bit binary equivalent.
  2. Concatenate the binary equivalents.

Exercises

EXERCISE 1-4: BINARY TO HEXADECIMAL

Convert these numbers, represented in binary, to their hexadecimal equivalents. Don’t convert to decimal if you can help it! The goal is to move directly from binary to hexadecimal.

10 (binary) = ______ (hexadecimal)

11110000 (binary) = ______ (hexadecimal)

EXERCISE 1-5: HEXADECIMAL TO BINARY

Convert these numbers, represented in hexadecimal, to their binary equivalents. Don’t convert to decimal if you can help it! The goal is to move directly from hexadecimal to binary.

1A (hexadecimal) = _____ (binary)

C3A0 (hexadecimal) = ______ (binary)

Picture
Published on
KembaraXtra-Computer Science-Number Systems
1. Introduction
  • Computers are digital machines that operate using 0s and 1s.
  • Understanding number systems is essential to understanding how computers work with numbers.
2. Decimal Numbers (Base 10)
  • The number system humans commonly use.
  • Uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
  • Employs place-value notation
2.1 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.
2.2 Powers of Ten
  • 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.)
2.3 Symbols
  • 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.
3. Binary Numbers (Base 2)
  • 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.
3.1 Place-Value Notation in Binary
  • 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
3.2 Converting Binary to Decimal
  • Multiply the symbol in each place by the place-value weight (power of 2) and sum the results.
3.3 Converting Decimal to Binary
  • 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.
3.4 Notation
  • 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.
·


Picture
Published on
KembaraXtra-Computer Science- Bits and Bytes
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).
Understanding Bits
  • A single bit can represent two states: 0 or 1 (off or on).
  • To represent more complex information, bits are combined into sequences.
Bytes: Grouping Bits for Manageability
  • Computers group bits into bytes (8 bits) for easier management.
Calculating Combinations
  • 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
Application
  • 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.



Picture
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.


Picture
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.


Picture
Published on

KembaraXtra-Computer Science: Analog vs. Digital

I. Introduction

Goal: Understand the fundamental differences between analog and digital representations of data.

Importance: Essential for comprehending how computers work.

II. The Analog Approach

Concept: Represents data by analogy, where one property corresponds to another. Values are continuous and potentially infinite.

Examples:

    - Scale: Needle position on a numbered line represents weight.

    - Thermometer: Mercury's volume represents temperature.

    - Phonograph record: Groove shape represents audio waveform.

    - Film-based cameras: Chemical changes on film represent the captured image.

Key Characteristics:

    - Continuous Variation: Analog values can vary infinitely within a range.

    - Approximation: Measurements are often approximations due to limitations in reading the analog representation.

    - Analogy: The representation is an analogy of the original data.

III. Going Digital

Concept: Represents data as a sequence of discrete symbols, chosen from a limited set of values.

Symbols Used: In most modern computers, the symbols are 0 and 1.

Key Characteristics:

    - Discrete Values: Digital systems use a finite set of symbols.

    - Sequences: Complex data is represented by sequences of these symbols.

    - Accuracy: Digital representations can be accurately processed, stored, and copied.

Storage Methods:

    - CD/DVD: Bumps (0) and flat spaces (1).

    - Flash Drive: Electrical charges (0 and 1).

    - Hard Disk Drive: Magnetization (0 and 1).

    - Digital Circuits: Voltage levels (0 and 1).

Benefits for Computers:

    - Consistency: All data types can be represented using the same set of symbols.

    - Reliability: Easier to build hardware that accurately processes and stores digital data.

    - Accuracy: Digital data can be copied without losing fidelity.

Examples of Digital Data:

    - Photos

    - Songs

    - Documents

    - Apps

    - Websites

IV. Analog vs. Digital: Key Differences

Feature Analog Digital
Representation Continuous, proportional analogy Discrete symbols (e.g., 0 and 1)
Values Potentially infinite within a range Limited set of values
Accuracy Approximation, subject to interpretation High, can be copied without loss of fidelity
Storage Physical medium (groove, chemical change) Binary code (0s and 1s)
Data Integrity Can decay over time and lose fidelity More resistant to degradation
Computer Usage Difficult for computers to process Easily processed by computers

V. Analog Signal: A Broader Meaning

Definition: Sometimes, "analog" simply means "not digital," referring to a continuous signal that doesn't conform to digital values.

Important Note: Be aware that "analog" might not always imply an analogy of something else.

VI. Key Terms

Analog: Representation of data using continuous physical quantities.

Digital: Representation of data using discrete symbols (typically 0s and 1s).

Data: Attributes or characteristics of an object or concept.

Representation: A way of expressing data in a specific format.

Symbols: Distinct units in a digital system (e.g., 0 and 1).

Sequence: An ordered series of symbols used to represent complex data in a digital system.

Fidelity: The degree to which a copy accurately reproduces the original.

Analog signal: It simply means “not digital,” referring to a continuous signal that doesn't conform to digital values.

Picture
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.


Picture
Published on
KembaraXtra-Case Law-Software Terms Defined
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.
II. Relationship between Code Types
  • 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.
III. Core Concept
  • "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.
IV. Analogy
  • Human Language vs. Machine Language:
    • Vocabulary words are like CPU instructions.
    • Sentences formed from words are like programs formed from instructions. Both convey meaning.



Picture