Bit Wise concepts and tricks

 

Q) What is the difference between % (modulo) operator and bit wise & operator  in C. Which one is faster then other and why and when we should use & instead of %(modulo).

Q) If a variable v (uint) to contain two uint MASKs, the how will you do it.

http://graphics.stanford.edu/~seander/bithacks.html

http://sol.gfxile.net/boolean.html

Top coders tutorial:

http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=bitManipulation

10 ways to check if a number is a power of two:

http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s