XOR (Exclusive OR): A digital logic gate that implements an exclusive disjunction; outputs true or 1 if the inputs are different (1 and 0).
XNOR: The inverse of XOR; outputs true or 1 if the inputs are the same.
Similar to decimal addition, binary addition requires handling carries when the sum exceeds the base (2 for binary).
Example: Adding binary values representing decimal numbers involves a carry just like decimal addition (Example: 9 + 11 decimal = 20, so in binary: 1001 + 1011).
Half Adder: A circuit that adds two binary digits, producing a sum and a carry.
Truth Table:
Inputs (X, Y) and Outputs (Carry, Sum):
(0, 0) → Carry = 0, Sum = 0
(0, 1) → Carry = 0, Sum = 1
(1, 0) → Carry = 0, Sum = 1
(1, 1) → Carry = 1, Sum = 0
When adding multi-bit numbers, a Carry-in is utilized.
Example: Adding binary 001 + 011 results in a carry-out that moves into the next significant bit position.
Full Adder: A circuit that activates on carry otherwise behaves like half adder.
It adds three input bits: Two significant bits and a Carry-in.
Truth Table:
Inputs (X, Y, Ci) and Outputs (Carry-out, Sum):
Calculates Carry-out based on majority logic from inputs.
A type of adder built using full adders connected in series.
The sum is produced sequentially from least significant bit (LSB) to most significant bit (MSB), leading to higher delays due to propagation of carries.
Example: Adding 12 (1100) and 6 (0110) gives 18 (10010); in 4-bits this results in overflow which may not represent number correctly.
Overflow detection: Occurs when there's a carry-out from the MSB position.
Solutions: Allow for n+1 bits to handle adding two n-bit numbers.
Unsigned numbers: No sign bit is present in representation.
Signed numbers: The leftmost bit indicates the sign (0 for positive, 1 for negative).
Sign and Magnitude: Reserve the leftmost bit for the sign representation.
Not efficient as it complicates addition between numbers of different signs.
Negation of numbers is achieved by inverting the bits.
Example: To represent -14 from +14 the bits are inverted, +14 being (01110)2 changes to (10001)2 for -14.
To find negative of a binary number, take its one’s complement and add 1.
More efficient in modern computers than one’s complement.
One’s Complement: Utilized by early machines.
Two’s Complement: Dominated post-1960 due to industrial standards set by companies such as IBM.
Comparison Table (4-bit signed integers): Structure showing how different systems represent values from -8 to +7, highlighting that representation varies across systems such as sign & magnitude, one’s complement, and two’s complement.
Process illustrated to convert values like 7 to -7 by performing binary operations to find the two’s complement.
Potential for complexities requiring end-around carry to adjust sums properly.
Issues arise when adding two numbers of the same sign resulting in a different sign.
The process of repeating the sign bit to ensure the values remain represented correctly in wider bit-widths.
Functional block designed to perform addition and subtraction via control signals guiding the operation.