Generally machines support two forms of right shift

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: des a set of logical operators ||, &&, and !, which correspond to the O R, A ND, and N OT operations of propositional logic. These can easily be confused with the bit-level operations, but their function is quite different. The logical operations treat any nonzero argument as representing T RUE and argument 0 as representing FALSE. They return either 1 or 0 indicating a result of either T RUE or FALSE, respectively. Here are some example expression evaluations: Expression !0x41 !0x00 !!0x41 0x69 && 0x55 0x69 || 0x55 Result 0x00 0x01 0x01 0x01 0x01 Observe that a bit-wise operation will have behavior matching that of its logical counterpart only in the special case where the arguments are restricted to be either 0 or 1. A second important distinction between the logical operators && and ||, versus their bit-level counterparts & and | is that the logical operators do not evaluate their second argument if the result of the expression can be determined by evaluating the first argument. Thus, for exam...
View Full Document

Ask a homework question - tutors are online