Search:     Advanced search
Browse by category:
C/C++   |   Java   |   Oracle/Database   |   SAP   |   ASP .NET   |   Mainframe-DB2   |   Freshers

Check if the 20th bit of a 32 bit integer is on or off?

Add comment
Views: 348
Votes: 0
Comments: 0

if((num & x00001000)==x00001000)

 

Note that the digits represented here are in hex.


0 0 0 0 1 0 0 0
^
|

x0000 0000 0000 0000 0001 0000 0000 0000 = 32 bits

^ ^ ^
| | |

0th bit 20th bit 32nd bit

Others in this Category
document How many different trees can be constructed using n nodes?
document Q: In the WHERE clause what is BETWEEN and IN?
document Q: What are the contents of a DCLGEN?
document What is an AVL tree?
document Q: Is BETWEEN inclusive of the range values specified?
document Q: How would you retrieve rows from a DB2 table in embedded SQL?
document 1.Can you construct a tree using postorder and preorder traversal?
document Write pseudocode to add a new node to a Binary Search Tree (BST)
document Implement Breadth First Search (BFS) and Depth First Search (DFS)
document Find the closest ancestor of two nodes in a tree.
» More articles



RSS