## Search this website:

## Main Menu

# Pdf on Bitwise operators and their functios

- 4-28-2009
- Categorized in: Interview Questions/Tutorials

Following are some excerpts from the document

Manipulating Rightmost Bits

Some of the formulas in this section find application in later chapters.

Use the following formula to turn off the rightmost 1-bit in a word, producing 0 if none (e.g., 01011000

⇒ 01010000):

This may be used to determine if an unsigned integer is a power of 2; apply the formula followed by a 0-test on the result.

Similarly, the following formula can be used to test if an unsigned integer is of the form (including 0 or all 1’s):

Use the following formula to isolate the rightmost 1-bit, producing 0 if none (e.g., 01011000

⇒ 00001000):

Use the following formula to isolate the rightmost 0-bit, producing 0 if none (e.g., 10100111

⇒ 00001000):

Use one of the following formulas to form a mask that identifies the trailing 0’s, producing all 1’s if (e.g., 01011000

⇒ 00000111):

The first formula has a little instruction-level parallelism.

Download the whole document in the attachment section

### Attachments

### Email to Friend

Fill in the form below to send this article to a friend:

Why does it say written by Abhishek Kumar, when it is Henry S. Warren Jr.'s book: "Hacker's Delight"?