.

Tuesday, February 26, 2013

Bitwise

C HA PT ER 2

BASICS
21 Manipulating Rightmost Bits
Some of the patterns in this section find use in later chapters. Use the pastime runula to lift off the right 1-bit in a word, producing 0 if no(prenominal) (e.g., 01011000 ? 01010000): x & (x 1) This may be utilize to determine if an unsigned integer is a power of 2; apply the abidanceula followed by a 0-test on the result. Similarly, the interest formula john be used to test if an unsigned integer is of the form 2 n 1 (including 0 or tot all in ally 1s): x & (x + 1) Use the following formula to sequester the rightmost 1-bit, producing 0 if none (e.g., 01011000 ? 00001000): x & ( x) Use the following formula to isolate the rightmost 0-bit, producing 0 if none (e.g., 10100111 ? 00001000): ¬x & ( x + 1 ) Use one of the following formulas to form a mask that identifies the tracking 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 trailing 0s, producing all 1s if x = 0 (e.g.

Ordercustompaper.com is a professional essay writing service at which you can buy essays on any topics and disciplines! All custom essays are written by professional writers!

, 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 duals in the following sense. Read what the formula does, interchanging 1s and 0s in the description. Then, in the formula, knock 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: Ordercustompaper.com



If you want to get a full essay, wisit our page: write my paper

No comments:

Post a Comment