I'm currently doing bitwise operations, and I found a method in which the reference to the position in the 8-bit array is not clear to me.
Here is an example: all the numbers I have chosen at random for explanation only, the method itself is much more complicated (the array can be initialized with any size large enough):
void method(int pos, uint8_t* array_of_num) {
int dim = 5;
uint8_t numbers[4] = {1, 8, 32, 64};
int size = 10;
int i = 0;
for (i=0; i < size; i++){
array_of_num[pos + i/4] |= numbers[i%4];
}
}
I don’t understand what position "array_of_num [pos + i / 4]" refers to. array_of_num is an array of 8-bit uints, so it looks like this:
[0] ----> 1 (00000001);
[1] ----> 5 (00000101);
[2] ----> ......
This applies to some int bits at a position in the array, but if so, then as an operand - | - takes into account only these bits, since the numbers [] are also 8 uint bits. Let me try to explain what I mean in this example, so this is:
pos = 0; i = 1
array_of_num[0 + 1/4] |= 00001000
will not be the same if we just write:
array_of_num[0] |= 00001000