Answer the question
In order to leave comments, you need to log in
Bitwise array shift?
There is an array like [FFFF, FFFF, ...., FFFF, 3FFF] , you need to get [7FFF, FFFF, ...., FFFF, 9FFF], that is, shift the entire array by one bit. As I understand it, similar tasks in C are solved by assembler inserts, because there it is possible to save the bit displaced by the shift. But I'm interested in any solution to this problem)
Answer the question
In order to leave comments, you need to log in
pseudocode
int mask=0;
for i in 0..len(arr)-1{
int newmask = arr[i]&1==0 ? 0 :0x8000;//
arr[i]=(arr[i]>>1) | mask;
mask = newmask;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question