C Programming Find position of the only set bit – Given a number having only one ‘1’ and all other ’0’s in its binary representation.
bitwise operations in c
Write a one line C function to return position of first 1 from right to left, in binary representation of an Integer.
C Program to find whether a no is power of two – Bit Algorithm – Given a positive integer, write a function to find if it is a power of two or not.
Count set bits in an integer in C Programming – Bit Algorithm – Simple Method Loop through all bits in an integer, check if bit is set and if then increment
C Program to Reverse Bits of a Number – Bit Algorithm – Given an unsigned integer, reverse all bits of it and return the number with reversed bits.
Rotate bits of a number – Bit Algorithm – A rotation (or circular shift)is an operation similar to shift except that the bits that fall off at one end
Compute the integer absolute value without branching – Bit Algorithm – We need not do anything if a no is positive. We want to change only negative numbers.
Multiply a given Integer with 3.5 – Bit Algorithm – Given a integer x, write a function that multiplies x with 3.5 and returns the integer result.
Next higher number with same number of set bits – Bit Algorithm – When we observe the binary sequence from 0 to 2n – 1 (n is # of bits),The idea is to find right most string of 1’s in x, and shift the pattern to right extreme
Program to count number of set bits in an (big) array- Bit Algorithm – The simple approach would be, create an efficient method to count set bits in a word.