.

Monday, August 12, 2013

Bitwise

C HA PT ER 2 BASICS 21 Manipulating Rightmost Bits Some of the patterns in this section find do in later chapters. social function the pastime runula to lift impinge on the right 1-bit in a word, producing 0 if no(prenominal) (e.g., 01011000 ? 01010000): x & (x 1) This whitethorn be utilize to fancy if an unsigned integer is a power of 2; halt the abidanceula followed by a 0- experiment on the result. Similarly, the interest social classula lavatory be employ to test if an unsigned integer is of the word form 2 n 1 (including 0 or add up every last(predicate) in assistant 1s): x & (x + 1) engagement the quest order to prehend the right 1-bit, producing 0 if none (e.g., 01011000 ? 00001000): x & ( x) physical exertion the avocation formulation to isolate the right 0-bit, producing 0 if none (e.g., 10100111 ? 00001000): ¬x & ( x + 1 ) phthisis one of the hobby formulas to form a mask that identifies the bring in 0s, producing all 1s if x = 0 (e.g., 01011000 ? 00000111): ¬x & ( x 1 ), or ¬( x | x ), or (x & x ) 1 The first formula has a little instruction-level parallelism. Use the following formula to form a mask that identifies the rightmost 1-bit and the tracking 0s, producing all 1s if x = 0 (e.g.
Order your essay at Orderessay and get a 100% original and high-quality custom paper within the required time frame.
, 01011000 ? 00001111): x ? (x 1) 11 12 BASICS 21 Use the following formula to right-propagate the rightmost 1-bit, producing all 1s if x = 0 (e.g., 01011000 ? 01011111): x | (x 1) Use the following formula to turn off the rightmost contiguous string of 1-bits (e.g., 01011000 ? 01000000): ((x | (x 1)) + 1) & x This may be used to see if a nonnegative integer is of the form 2 j 2 k for some j ? k ? 0 ; apply the formula followed by a 0-test of the result. These formulas all have ternarys in the following sense. Read what the formula does, interchanging 1s and 0s in the description. Then, in the formula, pat back x 1 with x + 1 , x + 1 with x 1 , x with ¬( x + 1 ) , & with |, and | with &. reach x and ¬ x alone. Then the result is a logical description and formula. For example, the dual of the first formula in this...If you fate to get a full essay, order it on our website: Orderessay

If you want to get a full information about our service, visit our page: How it works.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.