ICS Day 1
ICS Day 1
● A number system defines how numbers are represented using digits and symbols.
● Allows arithmetic operations like addition, subtraction, multiplication, and division.
● Numbers can represent various forms, such as names, colors, or events.
1. Binary
○ Base:
○ Symbols: 0,1
○ Used in computers due to simplicity and reliability.
2. Octal
○ Base: 8
○ Symbols: 0−7
3. Decimal
○ Base: 10
○ Symbols: 0−9
○ Commonly used by humans due to its easy readability.
4. Hexadecimal
○ Base: 16
○ Symbols: 0−9,A−F
Limitations in Computers:
1. Storage Complexity:
○ Decimal requires 10 symbols, leading to large circuitry for storage.
2. Transmission Challenges:
○ Encoding 10 signal levels for transmission requires high precision to minimize
errors.
3. Design Complications:
○ Handling 10 signal levels complicates arithmetic and logical operations.
The decimal number system, used in everyday life (e.g., currency, phone numbers), is not
directly usable in digital systems. Computers rely on the binary number system, which
consists of only two digits: 0 and 1. Binary numbers represent signals as follows:
● 1: Presence of a signal.
● 0: Absence of a signal.
● Least Significant Bit (LSB): The rightmost bit, with the smallest weight.
● Most Significant Bit (MSB): The leftmost bit, with the largest weight.
1. Integer Part:
○ Use successive division by 2.
○ Record remainders (bottom-to-top sequence for the binary number).
2. Example: Convert 125125125 to binary.
○ 125÷2=62(remainder = 1).
○ 62÷2=31 (remainder = 0).
○ Continue until the quotient is 000.
○ Binary equivalent: 1111101.
3. Fractional Part:
○ Use successive multiplication by 2.
○ Record integer parts (top-to-bottom sequence for the binary number).
4. Example: Convert 0.660.660.66 to binary.
○ 0.66×2=1.32 (integer = 1).
○ 0.32×2=0.64 (integer = 0).
○ Continue for desired accuracy.
○ Binary equivalent (up to 4 digits): 0.1010.
5. Final Binary Representation: Combine results, e.g., 125.66→1111101.1010125.66
Why Use Octal and Hexadecimal Systems?
Computers process data in binary, but large binary sequences are hard for programmers to
handle. Octal (base 8) and hexadecimal (base 16) systems offer more compact representations:
● A table listing all possible input combinations and their corresponding outputs in a logic
circuit.
● For n binary inputs, there are 2^n possible combinations. For example:
○ 1 input → 2 combinations: 0,1
○ 2 inputs → 4 combinations: 00,01,10,11
○ 3 inputs → 8 combinations, and so on.
2. Bitwise Addition:
● Adds binary numbers bit by bit, resulting in two outputs: Sum and Carry.
● Truth Table for addition of two inputs AAA and BBB:
A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
● Start from the Least Significant Bit (LSB) and use the truth table for reference.
● Final result (including carry): 11,001.
3. 1's Complement:
4. 2's Complement:
Applications:
Despite its ease of use in representation, the signed magnitude representation is not ideal for
computer arithmetic due to these limitations. Alternative methods, like two's complement, are
often used in practice to overcome these issues.
The four cases evaluated show how the result's sign depends on the signs of the operands
involved.
The video you're referencing addresses two important concepts in binary arithmetic: sign
extension and overflow condition. Here's a detailed breakdown of the key points discussed:
● The example starts with adding 00110100 (52 in decimal) and 10001 (-15 in decimal,
after applying two's complement).
● The main issue is the misalignment of sign bits. The first number is 8 bits, while the
second one is only 5 bits.
● Sign Extension is the process of increasing the bit-width of a binary number while
preserving its value and sign. This is done by copying the sign bit (MSB) to the newly
added bits.
○ For example, 10001 (which represents -15) is sign-extended to 11100001, filling
the extra bits with the sign bit 1.
● After sign extension, the numbers can be properly added together, and the result is
correct: 37 (in decimal).
2. Overflow Condition:
● Overflow occurs when the result of an arithmetic operation cannot be represented within
the available number of bits.
● For instance, when adding two 5-bit numbers +10 and +8, we get +18, which exceeds
the maximum value that can be represented with 5 bits (which is 15). The result, 10010
(which is -14 in decimal), is incorrect due to overflow.
● How to detect overflow:
○ Overflow occurs when two numbers of the same sign (both positive or both
negative) are added and the result has the opposite sign.
○ In the example, both numbers were positive, but the result was negative,
indicating an overflow condition.
3. Summary:
● Sign extension ensures that the number's value and sign are preserved when
increasing the number of bits.
● Overflow happens when the result of an operation exceeds the range that can be
represented with the given number of bits. In most programming languages, overflow is
treated as an exception that needs to be properly handled.
The video explains the working principles of various logic gates, which are essential
components in digital circuits. Here's a breakdown of the gates discussed and their
characteristics:
1. AND Gate:
0 0 0
0 1 0
1 0 0
1 1 1
● Expression: Y = A.B
2. OR Gate:
0 0 0
0 1 1
1 0 1
1 1 1
● Expression: Y = A + B
3. NOT Gate:
1 0
● Expression: Y = A'
0 0 0
0 1 1
1 0 1
1 1 0
●
Expression: Y = A ⊕ B
● Important Note: For multiple inputs, the output is 1 if the number of 1's is odd;
otherwise, the output is 0.
0 0 1
0 1 0
1 0 0
1 1 1
0 0 1
0 1 1
1 0 1
1 1 0
7. NOR Gate:
0 0 1
0 1 0
1 0 0
1 1 0
Summary:
● Basic Gates: AND, OR, and NOT are the fundamental gates used in digital circuits.
● Derived Gates: XOR, XNOR, NAND, and NOR are derived from the basic gates and
provide more complex operations for implementing various logic functions.
● Truth Tables: They define the behavior of each gate by specifying the output for every
possible input combination.
The video explains binary codes used to represent, store, and transmit data in computers. It
covers two key codes: BCD (Binary Coded Decimal) and ASCII (American Standard Code
for Information Interchange).
● Definition: BCD is a binary encoding of decimal numbers, where each decimal digit is
represented by 4 binary bits.
● Also Known As: 8421 Code (because each decimal digit is represented using 8421
weights in binary).
● Example:
○ Decimal 10 in binary is 1010, but BCD for 10 would encode each digit separately:
■ 1 → 0001
■ 0 → 0000
● BCD to Decimal Conversion: To convert BCD to decimal, group the binary code in
groups of 4 bits and then convert each group back to decimal.
○ For example, BCD 0111 0101 1001 → Decimal 759.
● Types of BCD Representation:
○ Unpacked BCD: Each decimal digit is stored in a separate byte (8 bits), making
it less memory efficient.
○ Packed BCD: Two decimal digits are stored in a single byte (8 bits), where each
nibble (4 bits) represents one decimal digit. This is more memory efficient.
○ Example:
■ For 48, in packed BCD:
■ 8 is represented as 1000 (lower nibble),
■ 4 is represented as 0100 (upper nibble).
2. ASCII Code:
Summary:
● BCD is used to represent decimal digits using binary and has two forms: unpacked (less
efficient) and packed (more memory-efficient).
● ASCII provides a way to encode text characters, using 7 bits for data and an 8th bit for
error checking, allowing computers to handle a wide range of textual information,
including control characters.
1. BCD Addition:
● Procedure:
○ Add the BCD digits (4 bits) of two decimal numbers.
○ If the result is less than or equal to 9 (1001 in binary), it's valid.
○ If the result is greater than 9 (1010 or more), add 6 (0110) to the result and carry
the overflow to the next nibble.
○ Continue the process for each nibble (4 bits) and add any carry generated.
● Example: Add 395 (A) and 413 (B):
○ A = 395 → BCD representation: 0011 (3), 1001 (9), 0101 (5)
○ B = 413 → BCD representation: 0100 (4), 0001 (1), 0011 (3)
○ Adding the corresponding nibbles:
■ First nibble: 1000 (8), which is valid.
■ Second nibble: 1010 (10), which is invalid. Add 0110 (6), resulting in
0000 with a carry of 1.
■ Third nibble: 1000 (8) with carry, which is valid.
○ Final result: 808 (correct decimal sum).
● Procedure:
○ Use 10's complement to represent the negative number.
○ 10's complement is the 9's complement plus 1.
○ Perform the addition of the original number and the negative (10's complement)
of the second number, following BCD addition rules.
● Example: Subtract 239 (B) from 475 (A):
○ A = 475 → BCD: 0100 (4), 0111 (7), 0101 (5)
○ B = 239 → BCD: 0010 (2), 0011 (3), 1001 (9)
○ Find 10's complement of B:
■ 9's complement of 239 → 760 (subtract from 999).
■ Add 1 to 760 → 761 (10's complement).
○ Add A and the 10's complement of B:
■ First nibble: 0110 (6), valid.
■ Second nibble: 1101 (13), add 6 → 0110, carry 1.
■ Third nibble: 0010 (2) with carry, add 6 → 0110, discard carry.
○ Final result: 236 (correct decimal result).
Summary:
● BCD Addition: Add the corresponding nibbles and handle carries. If a result is greater
than 9, add 6 to make it valid.
● BCD Subtraction: Use 10's complement (9's complement + 1) to represent the negative
and then add it to the original number.