>Can somebody explain to me how: "a[i]+-~j" is the same as "a[i]+(j+1)" ?
-(~j) = Twos complement of the ones complement of j
Twos complement = ones complement + 1
So twos complement of (ones complement of j) = ones complement of (ones complement of j) + 1 = j + 1