**‘Recent Articles’ on Bit Magic**

**Topic :**

- Find the element that appears once
- Detect if two integers have opposite signs
- Add 1 to a given number
- Multiply a given Integer with 3.5
- Turn off the rightmost set bit
- Find whether a given number is a power of 4 or not
- Compute modulus division by a power-of-2-number
- Rotate bits of a number
- Find the Number Occurring Odd Number of Times
- Check for Integer Overflow
- Little and Big Endian Mystery
- Count set bits in an integer
- Count number of bits to be flipped to convert A to B
- Efficient way to multiply with 7
- Program to find whether a no is power of two
- Position of rightmost set bit
- Binary representation of a given number
- Find position of the only set bit
- How to swap two numbers without using a temporary variable?
- Swap two nibbles in a byte
- How to turn off a particular bit in a number?
- Russian Peasant (Multiply two numbers using bitwise operators)
- Add two bit strings
- Write your own strcmp that ignores cases
- Check if two numbers are equal without using arithmetic and comparison operators
- Find XOR of two number without using XOR operator
- XOR counts of 0s and 1s in binary representation
- Calculate XOR from 1 to n
- Multiply a number with 10 without using multiplication operator
- Equal Sum and XOR
- Swap three variables without using temporary variable
- Check if a number has bits in alternate pattern
- Count minimum bits to flip such that XOR of A and B equal to C
- Efficient method for 2’s complement of a binary string
- Toggle case of a string using Bitwise operators
- Toggling k-th bit of a number
- Convert decimal fraction to binary number
- Toggle all the bits of a number except k-th bit
- Set the rightmost unset bit
- Convert a binary number to octal
- Check in binary array the number represented by a subarray is odd or even
- Toggle the last m bits
- 1 to n bit numbers with no consecutive 1s in binary representation
- Toggle bits in the given range
- Unset bits in the given range
- Find the largest number with n set and m unset bits
- Find the smallest number with n set and m unset bits
- Sum of numbers with exactly 2 bits set
- Check if binary representation of a given number and its complement are anagram
- Josephus Problem Using Bit Magic

- Swap bits in a given number
- Add two numbers without using arithmetic operators
- Smallest of three integers without comparison operators
- A Boolean Array Puzzle
- Compute the integer absolute value (abs) without branching
- Compute the minimum or maximum of two integers without branching
- Find the two non-repeating elements in an array of repeating elements
- Write an Efficient C Program to Reverse Bits of a Number
- Smallest power of 2 greater than or equal to n
- Write an Efficient Method to Check if a Number is Multiple of 3
- Write a C program to find the parity of an unsigned integer
- Swap all odd and even bits
- Check if a number is multiple of 9 using bitwise operators
- Check if binary representation of a number is palindrome
- Generate n-bit Gray Codes
- Check if a given number is sparse or not
- Euclid’s Algorithm when % and / operations are costly
- Find nth Magic Number
- How to swap two bits in a given integer?
- Calculate 7n/8 without using division and multiplication operators
- Calculate square of a number without using *, / and pow()
- Generate 0 and 1 with 25% and 75% probability
- Find even occurring elements in an array of limited range
- Cyclic Redundancy Check and Modulo-2 Division
- Copy set bits in a range
- Check if a number is Bleak
- Count strings with consecutive 1’s
- Gray to Binary and Binary to Gray conversion
- Find Next Sparse Number
- Sum of bit differences among all pairs
- Sum of Bitwise And of all pairs in a given array
- Bitwise and (or &) of a range
- Multiples of 4 (An Interesting Method)
- Length of the Longest Consecutive 1s in Binary Representation
- Pairs of complete strings in two sets of strings
- Find profession in a special family
- Print first n numbers with exactly two set bits
- Check if bits of a number has count of consecutive set bits in increasing order
- Subset sum queries using bitset
- Maximum 0’s between two immediate 1’s in binary representation
- Count all pairs of an array which differ in K bits
- Efficiently check if a string has duplicates without using any additional data structure
- Count trailing zero bits using lookup table
- Count smaller numbers whose XOR with n produces greater value
- Check divisibility in a binary stream
- Multiplication of two numbers with shift operator
- Determine if a string has all Unique Characters
- Reverse an array without using subtract sign ‘-‘ anywhere in the code
- Count numbers whose sum with x is equal to XOR with x
- Maximum XOR value of a pair from a range
- Numbers whose bitwise OR and sum with N are equal
- Change bits to make specific OR value
- Count smaller values whose XOR with x is greater than x
- Next greater integer having one more number of set bits
- Check if two numbers are bit rotations of each other or not
- Previous smaller integer having one less number of set bits
- Check if binary representations of two numbers are anagram
- Maximize a given unsigned number number by swapping bits at it’s extreme positions
- Set bits in N equals to M in the given range

- Count total set bits in all numbers from 1 to n
- Program to count number of set bits in an (big) array
- Next higher number with same number of set bits
- Karatsuba algorithm for fast multiplication
- Find the maximum subarray XOR in a given array
- Inserting m into n such that m starts at bit j and ends at bit i
- Find Duplicates of array using bit array
- Find longest sequence of 1’s in binary representation with one flip
- Closest (or Next) smaller and greater numbers with same number of set bits
- Bitmasking and Dynamic Programming | Set-2 (TSP)
- Compute the parity of a number using XOR and table look-up

- Interesting Facts about Bitwise Operators in C
- Optimization Techniques | Set 1 (Modulus)
- What are the differences between bitwise and logical AND operators in C/C++?
- Bit Fields in C
- C++ bitset and its application
- C++ bitset interesting facts
- Builtin functions of GCC compiler
- Bit Tricks for Competitive Programming

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.