This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 1 TA C162 Computer Programming I Virendra S Set2 Today’s Agenda c What we have done so far c Representations of Numbers c Arithmetic operations on bits •What’s next… • Logical operations on bits h AND h OR h NOT h XOR 2 TA C162 Computer Programming I Virendra S Set2 Logical Operations •Logical operations operate on logical variables . •Logical variable can have values either 0 or 1 •Basic logical functions: • AND • OR • NOT • XOR( Exclusive OR) •Operations on logical TRUE or FALSE • Two states  takes one bit to represent: h TRUE=1, FALSE=0 •View nbit number as a collection of n logical values • Operation applied to each bit independently 3 TA C162 Computer Programming I Virendra S Set2 Logical AND Operation • Binary logical operation • Needs two operands • Truth Table A B A AND B 1 1 1 1 1 The output is 1 only if both the operands have value 1 Example: Let A =10011001 B =00110011 A AND B = 00010001 Used for Clearing Bits AND with zero b AND with one b no change 4 TA C162 Computer Programming I Virendra S Set2 Logical OR Operation •Binary logical operation • Needs two operands •Truth Table A B A OR B 1 1 1 1 1 1 1 The output is 1 if any of the two operands are 1 Example: Let A =10011001 B =00110011 A OR B = 10111011 Useful for setting the bits OR with 0 b No change OR with 1 b Set the bit to 1 5 TA C162 Computer Programming I Virendra S Set2 Logical NOT Operation •Unary logical operation • Needs only one operand Truth Table: A NOT A 1 1 Example: Let A = 11000101 NOT A = 00111010 c Flips all bits of an operand c Also known as Complement operation c Used to take 1’s complement of a number 6 TA C162 Computer Programming I Virendra S Set2 Logical XOR Operation •Binary logical operation • Needs two operands •Truth Table A B A X OR B 1 1 1 1 1 1 The output is 0 if both operands are same Example Let A= 10011001, B= 11001010 A XOR B = 01010011 c Used to check two numbers are identical or not c If A and B are identical then A XOR B b all bits 0 c If A and B are not identical then A XOR B b all bits 1 7 TA C162 Computer Programming I Virendra S Set2 Transistor: Building Block of Computers • Microprocessors contain millions of transistors • Intel Pentium 4 (2000): 48 million...
View
Full Document
 Spring '09
 SHANTA
 Logic, Computer Programming, Boolean Algebra, Logic gate, exclusive or

Click to edit the document details