Idea: Preliminary view it is difficult to analyze the meaning of the expression at a glance, we might like to analyze the example, assuming that n = 5, the binary is represented as 101, then n-1 = 4, the binary is expressed as, 5 & 4 = 101 & 100 = 100 = 4! = 0, let's look at more examples below
5 4 101 - 4 6 5 the 101 4 7 6 111 the 6 8 7 + 0111 0
We will find that to make the expression equal to 0,n-1, we must make the n-1 of n be 1 high, that is to say, satisfy the condition:
1 =0
Let's see if there are those numbers that can meet the requirements:
10 & 01 = 0 -------2 ^1 100 & 011 = 0 -------2 ^2 1000 & 0111 = 0 -------2 ^3 01111 = 0 -------2 ^4 > ...
The so-called code ((N & (n-1)) = = 0) means that n satisfies the n-th-square of 2
The problem is usually to examine the ability to analyze and solve problems.
Explain the meaning of the code ((N & (n-1)) = = 0)