I found this bit of code (no pun intended) that solves a problem I needed to solve but I don't really understand what the (i & (1 << j)) part does. Is there a more "high level" way of writing it so I can understand it? Or a different way of doing the same thing that is less "pure"?
//this is not the actual code, just bits of it so you have an idea of how the variables are used
for (i = 0; i < vectorsize; i++) {
void findsubsets(unsigned int *value, int n, int i)
}
void findsubsets {
for (j = 0; j < n; j++) {
if (i & (1 << j)) {
//print something
}
}
}
I would like an alternative to that statement, that does the same thing (or rather, solves the same problem) but is more "usual". I am of course only referring to the bitwise shift.