Bitwise Algorithms | Basic

 

  1. Find the element that appears once
  2. Detect if two integers have opposite signs
  3. Add 1 to a given number
  4. Multiply a given Integer with 3.5
  5. Turn off the rightmost set bit
  6. Find whether a given number is a power of 4 or not
  7. Compute modulus division by a power-of-2-number
  8. Rotate bits of a number
  9. Find the Number Occurring Odd Number of Times
  10. Check for Integer Overflow
  11. Count set bits in an integer
  12. Count number of bits to be flipped to convert A to B
  13. Efficient way to multiply with 7
  14. Program to find whether a no is power of two
  15. Position of rightmost set bit
  16. Binary representation of a given number
  17. Find position of the only set bit
  18. How to swap two numbers without using a temporary variable?
  19. Swap two nibbles in a byte
  20. How to turn off a particular bit in a number?
  21. Russian Peasant (Multiply two numbers using bitwise operators)
  22. Add two bit strings
  23. Write your own strcmp that ignores cases
  24. Check if two numbers are equal without using arithmetic and comparison operators
  25. Find XOR of two number without using XOR operator
  26. XOR counts of 0s and 1s in binary representation
  27. Calculate XOR from 1 to n
  28. Equal Sum and XOR
  29. Swap three variables without using temporary variable
  30. Check if a number has bits in alternate pattern
  31. XOR of two numbers after making length of their binary representations equal
  32. Count minimum bits to flip such that XOR of A and B equal to C
  33. Efficient method for 2’s complement of a binary string
  34. Toggle case of a string using Bitwise operators
  35. Toggling k-th bit of a number
  36. Convert decimal fraction to binary number
  37. Toggle all the bits of a number except k-th bit
  38. Set the rightmost unset bit
  39. Convert a binary number to octal
  40. Check in binary array the number represented by a subarray is odd or even
  41. Toggle the last m bits
  42. 1 to n bit numbers with no consecutive 1s in binary representation
  43. Toggle bits in the given range
  44. Unset bits in the given range
  45. Find the largest number with n set and m unset bits
  46. Find the smallest number with n set and m unset bits
  47. Sum of numbers with exactly 2 bits set
  48. Check if binary representation of a given number and its complement are anagram
  49. Check a number is odd or even without modulus operator
  50. Bitwise recursive addition of two integers
  51. Print bitwise AND set of a number N
  52. Fast average of two numbers without division
  53. Maximum XOR-value of at-most k-elements from 1 to n
  54. Swap every two bits in bytes
  55. Check if a number is divisible by 8 using bitwise operators
  56. Number of Reflexive Relations on a Set
  57. For every set bit of a number toggle bits of other
  58. Toggle bits of a number expect first and last bits
  59. Check if given four integers (or sides) make rectangle
  60. Toggle all even bits of a number
  61. Toggle first and last bits of a number
  62. Set the Left most unset bit
  63. Maximum XOR using K numbers from 1 to n
  64. Python | Count set bits in a range
  65. Python map function | Count total set bits in all numbers from 1 to n
  66. Check whether the bit at given position is set or unset
  67. Multiplication with a power of 2
  68. Check if n is divisible by power of 2 without using arithmetic operators
  69. Toggle all odd bits of a number
  70. Count set bits using Python List comprehension
  71. Check if a number is positive, negative or zero using bit operators
  72. Modify a bit at a given position
  73. CHAR_BIT in C
  74. Find One’s Complement of an Integer
  75. Add two numbers without using arithmetic operators
  76. Multiply a number with 10 without using multiplication operator
  77. Check if one of the numbers is one’s complement of the other
  78. Check if a number has bits in alternate pattern | Set-2 O(1) Approach
  79. Set all the bits in given range of a number
  80. Calculate 7n/8 without using division and multiplication operators
  81. Count total bits in a number
  82. Find most significant set bit of a number
  83. Find smallest number n such that n XOR n+1 equals to given k
  84. Check if a number has two adjacent set bits
  85. Write an Efficient Method to Check if a Number is Multiple of 3
  86. Extract ‘k’ bits from a given position in a number
  87. Print ‘K’th least significant bit of a number
  88. Check if two numbers are equal without using comparison operators
  89. Efficiently check whether n is a multiple of 4 or not
  90. Check whether K-th bit is set or not
  91. Check if a number is multiple of 9 using bitwise operators
  92. Compare two integers without using any Comparison operator
  93. Multiplying a variable with a constant without using multiplication operator
  94. Check whether a given number is even or odd
  95. Powers of 2 to required sum
  96. Set all even bits of a number
  97. Set all odd bits of a number
  98. Print numbers having first and last bits as the only set bits
  99. Check if binary representations of two numbers are anagram
  100. Multiples of 4 (An Interesting Method)
  101. Given a set, find XOR of the XOR’s of all subsets.
  102. Write a function that returns 2 for input 1 and returns 1 for 2
  103. Subtract two numbers without using arithmetic operators

Quick Links :

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.



My Personal Notes arrow_drop_up


Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.