Let's see this line :
possible += (n_size[i] ^ n_size[i + 1]) < 0;
We don't know about n_size
but I'll suppose it is an array of n
int
. So we XOR (bitwise) two consecutive terms of n_size
, and determine the sign of the result (by comparing it to 0).
Bitwise-XOR is operating bit per bit, so (ABCD = 1011 ^ 0101
<=> A = 1 ^ 0
, B = 0 ^ 1
, C = 1 ^ 0
, D = 1 ^ 1
).
int
are encoded in a certain manner, which allows us to get the sign with the most-significant bit (in the number 0bX???????
, if X=1 the number is negative, else the number is positive).
So (A ^ B) < 0
is equivalent to (A < 0) ^ (B < 0)
.
So this line increments possible
when two consecutive terms have not the same sign.
Finally, possible
counts the number of consecutive terms alterning their sign.
PS : notice that float
and double
have their sign determined by their most-significant-bit too, so it works the same if n_size
is an array of float
or double
.