If go on to shift, we will see that it just takes one more power of 2. So, basically we can say that 1 << n (must have no space between) notation calculates the power of n as 2^n. A simple function implementation in C is like:
unsigned int power(unsigned int pow) {
int result=1 << pow;
return result;
}
0 comments:
Post a Comment