Here's an example of code in c, i'm not sure what does condition "k & 1" means.
int k,i,c;
k = i >> c;
if (k & 1)
printf("1");
else
printf("0");
Here's an example of code in c, i'm not sure what does condition "k & 1" means.
int k,i,c;
k = i >> c;
if (k & 1)
printf("1");
else
printf("0");
k & 1
does a bitwise AND operation of the k
variable and the 1
literal. The expression results in either 0
(if the LSB of k
is 0
) or 1
(if the LSB of k
is 1
). As the expression is the condition for the if
statement, it is implicitly cast to bool
, for which 1
maps to true
and 0
maps to false
.