Quantum Computing Simulation and Visualization  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Addition

high-level simulation, (x,y)->(x,(x+y)%M)
I = state index

x = I >> m;       // top m bits, M = 2m

y = I & mask;     // bottom m bits, mask = M-1 = 0111..1 (m 1's)

j = (x + y) % M;  // classical addition

J = (x << m) | j; // concatenate the bits

tj = a[J];        // temporarily save original a[J]

a[J] = a[I];      // update a[J]

add