Im trying to make use of bitwise operators, and my program is crashing when it reaches this point. It looks something like this:
short x = 1;
short insert = x << (some_number - 1);
/*some_number is always > 0*/
array[y][z] &= insert;
Is this the best way to use these operators, and where might the bug be coming from?
array[y][z]
is also a short, y
and z
are between 0 and 8 which was specified. some_number
can not exceed 9 as to not go out of the bit range of a short int. The idea is to insert a bit into a certain place depending on the value of some_number
.