Tuesday 12 March 2019

Basic Operators

Today we will be talking about operations. There are many different types of operations :
  • & - You can use it to check if a number is divisible by 2.
  • ^ - This is the XOR operator. XOR has property : the same number XOR the same number equal to zero.
  • 2 power n can be done in constant time with bit operation <<. Ex. (1<<n)
  • Multiplication and division are slower then bit operations. (n >>= 1) is equivalent as n /= 2.     (n <<= 1) is equivalent as n *= 2.
  • the or bit operation
  • n++ - increment n by 1
  • n-- - subtracts n by 1
  • ++n - increment n by 1
  • --n - subtracts n by 1
  • n%m = r - r is the remainder of the division n and m
  • *, -,  /, + - basic arithmetic operators

No comments:

Post a Comment

std::next_permutation(arr.begin(),arr.end());

What is next_permutation(a.begin(),a.end()) ? Next permutation is like what its name says, finds the next permutation of a and assigns ...