0% found this document useful (0 votes)
5 views15 pages

ICS Day 1

A number system defines how numbers are represented and allows arithmetic operations. There are two main types: non-positional (e.g., Roman numerals) and positional systems (e.g., binary, decimal, octal, hexadecimal), with binary being favored in computing for its simplicity. The document also covers binary arithmetic, representation of signed numbers, and the characteristics of various logic gates.

Uploaded by

skushal.mys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views15 pages

ICS Day 1

A number system defines how numbers are represented and allows arithmetic operations. There are two main types: non-positional (e.g., Roman numerals) and positional systems (e.g., binary, decimal, octal, hexadecimal), with binary being favored in computing for its simplicity. The document also covers binary arithmetic, representation of signed numbers, and the characteristics of various logic gates.

Uploaded by

skushal.mys
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

What is a Number System?

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

Types of Number Systems

1. Non-Positional Number Systems


○ Uses symbols to represent numbers, with no positional value.
○ Example: Roman Numerals (I, V, X, L, C, D, M).
○ Relies on specific rules for interpretation.
2. Positional Number Systems
○ The position of a digit determines its value.
○ Common examples: Decimal, Binary, Octal, Hexadecimal.
○ A number N(b)in a positional system has:
■ Integer Part: Digits to the left of the radix (decimal) point.
■ Fractional Part: Digits to the right of the radix point.
○ b: The base or radix, representing the number of unique symbols in the system.

Common Positional Number Systems

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

Decimal Number System

● Base Value: 10, using symbols 0−9.


Advantages:

● Easy to represent, read, and manipulate.

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.

Why Binary for Computers?

● Computers favor binary due to:


○ Simpler representation (000 and 111).
○ Easier implementation and processing.
○ Reliability in handling discrete signal levels.

Decimal and Binary Number Systems

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.

Each binary digit is called a bit.

● Least Significant Bit (LSB): The rightmost bit, with the smallest weight.
● Most Significant Bit (MSB): The leftmost bit, with the largest weight.

Positional Values in Binary Numbers

Binary numbers, like decimal numbers, are positional.

● Integer part: Bits are weighted as 2^0, 2^1, 2^2,,….


● Fractional part: Bits are weighted as 2^{-1}, 2^{-2}, 2^{-3},....

Data Units in Binary Systems

● Nibble: Group of 4 bits.


● Byte: Group of 8 bits.
● Word: 16 bits or 2 bytes.
● Double Word: 32 bits or 4 bytes.
● Quad Word: 64 bits or 8 bytes.

Decimal to Binary Conversion

Convert the integer and fractional parts separately:

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:

● Octal: Groups binary numbers into 3 bits.


● Hexadecimal: Groups binary numbers into 4 bits.

Octal Number System

1. Definition: Positional system using symbols 0–7 with base 8.


2. Conversion from Decimal to Octal:
○ Integer part: Divide repeatedly by 8, recording remainders (read bottom to top).
○ Fractional part: Multiply by 8, keeping integer parts (read top to bottom).
Hexadecimal Number System
1. Truth Table:

● 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

Example: Adding two 4-bit numbers, 1110 and 1011:

● Start from the Least Significant Bit (LSB) and use the truth table for reference.
● Final result (including carry): 11,001.
3. 1's Complement:

● Flip all bits in the binary number (0→1, 1→0).


● Example: 1's complement of 0001100 is 1110011.

4. 2's Complement:

● Derived by adding 1 to the 1's complement of a binary number.


● Shortcut:
○ Copy bits from right to left until the first 1 is encountered.
○ Flip all remaining bits.
● Example:
○ Binary: 0001100
○ 1's Complement: 1110011
○ Add 1: 1110100 (2's complement).

Applications:

● Bitwise addition forms the foundation of arithmetic operations in computers.


● 1's complement and 2's complement are essential for representing and processing
negative numbers in binary systems.

1. Binary Representation of Integers:


○ Unsigned Representation: Represents only positive numbers and zero. It uses
all bits to represent values. For n bits, there are 2n2^n2n possible values, with
one representing zero and the rest representing positive numbers.
■ Example: For a 3-bit number, the representations are:
■ 000 (0)
■ 001 (1)
■ 010 (2)
■ 011 (3)
■ 100 (4)
■ 101 (5)
■ 110 (6)
■ 111 (7)
2. Signed Magnitude Representation:
○ Represents both positive and negative numbers. The most significant bit (MSB)
is used to represent the sign:
■ If MSB is 0, the number is positive.
■ If MSB is 1, the number is negative.
○ For n bits, there are 2^n distinct combinations, with half positive and half negative
numbers.
■ Example: For a 3-bit number:
■ Positive numbers: 000, 001, 010
■ Negative numbers: 111, 110, 101
■ Zeros: 000 (positive zero), 100 (negative zero)
3. Issues with Signed Magnitude Representation:
○ Two representations for zero: Positive zero and negative zero.
○ Addition problems: Addition yields incorrect results for certain combinations.
■ Example:
■ Adding +2 (010) and -3 (111) results in +1 instead of -1.
■ Adding +3 (011) and -3 (111) results in +2 instead of 0.
4. Comparison of Unsigned and Signed Magnitude:
○ Unsigned numbers are not suitable for computing systems because they can
only represent positive numbers.
○ Signed magnitude allows representation of negative numbers but has
drawbacks:
■ Incorrect addition results in some cases.
■ Waste of one bit pattern due to two representations for zero.

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.

1. Two's Complement Representation: This method is primarily used for representing


signed binary numbers. It simplifies arithmetic operations on binary numbers like addition
and subtraction.
2. Addition and Subtraction Using Two's Complement:
○ Addition (A + B): This is straightforward. Both A and B are added bitwise from
the least significant bit (LSB) to the most significant bit (MSB). If there is a carry
from the MSB, it is ignored, and the result is the sum in two's complement.
○ Subtraction (A - B): Subtraction is performed by converting the subtraction to an
addition. For example, A - B is equivalent to A + (-B), where -B is obtained by
taking the two's complement of B.
3. Four Cases of Addition:
○ Case 1 (A + B): Both A and B are positive. The result is positive.
○ Case 2 (A - B): This is computed as A + (-B). In this case, the two's complement
of B is computed first, then added to A. If the result is positive, it's correct.
○ Case 3 (-A + B): This is equivalent to adding the two's complement of A to B. If
the result is negative, it indicates that the magnitude of A is greater than B.
○ Case 4 (-A - B): This is equivalent to adding the two's complement of both A and
B. The result is negative if both numbers are negative.
4. Summary:
○ Two's complement is used to perform both addition and subtraction.
○ The result of the operation is in two's complement form.
○ If there is a carry from the MSB in the addition, it is ignored. The final result will
depend on the sign of the larger magnitude number.

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:

1. Addition of Two Binary Numbers (Sign Extension):

● 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:

● Symbol: Two inputs (A and B) and one output (Y).


● Operation: The output is 1 only when both inputs are 1.
● Truth Table:
A B Y (A AND B)

0 0 0

0 1 0

1 0 0

1 1 1

● Expression: Y = A.B

2. OR Gate:

● Symbol: Two inputs (A and B) and one output (Y).


● Operation: The output is 0 only when both inputs are 0. Otherwise, the output is 1.
● Truth Table:
A B Y (A OR B)

0 0 0

0 1 1

1 0 1

1 1 1

● Expression: Y = A + B

3. NOT Gate:

● Symbol: One input (A) and one output (Y).


● Operation: The output is the complement of the input.
● Truth Table:
A Y (NOT A)
0 1

1 0

● Expression: Y = A'

4. XOR Gate (Exclusive OR):

● Symbol: Two inputs (A and B) and one output (Y).


● Operation: The output is 1 when the inputs are different (one is 0, the other is 1). If both
inputs are the same, the output is 0.
● Truth Table:
A B Y (A XOR B)

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.

5. XNOR Gate (Exclusive NOR):

● Symbol: Two inputs (A and B) and one output (Y).


● Operation: The output is 1 when both inputs are the same, and 0 when the inputs are
different.
● Truth Table:
A B Y (A XNOR B)

0 0 1

0 1 0

1 0 0

1 1 1

● Expression: Y = A ⊙ B (or complement of A ⊕ B)


6. NAND Gate:

● Symbol: Multiple inputs (A, B, etc.) and one output (Y).


● Operation: It is equivalent to the AND gate followed by a NOT gate. The output is 0 only
when all inputs are 1; for all other combinations, the output is 1.
● Truth Table:
A B Y (A NAND B)

0 0 1

0 1 1

1 0 1

1 1 0

● Expression: Y = A NAND B = (A.B)'

7. NOR Gate:

● Symbol: Two inputs (A and B) and one output (Y).


● Operation: It is equivalent to the OR gate followed by a NOT gate. The output is 1 only
when both inputs are 0. For all other combinations, the output is 0.
● Truth Table:
A B Y (A NOR B)

0 0 1

0 1 0

1 0 0

1 1 0

● Expression: Y = A NOR B = (A + B)'

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

1. BCD Code (Binary Coded Decimal):

● 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:

● Definition: ASCII is a character encoding standard used in computers to represent text


data. It uses 7 bits to represent 128 characters, with an additional 1 bit for parity (error
checking).
● Characters Represented:
○ Uppercase and lowercase letters (A-Z, a-z),
○ Digits (0-9),
○ Punctuation marks,
○ Control characters (e.g., newline, tab).
● Example:
○ The character A is represented by 01000001 (in 8 bits, with the 8th bit being a
parity bit for error detection).

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

2. BCD Subtraction (using 10's complement):

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

You might also like