I have a number in bitwise form (eg 10101111000010...), 30 digits long. Let it be
abcdefgh.....wxyz
I want a slick way to shift it around, so it stays 30 digits, but it is shifted 3, but the top three are then put at the bottom.
defgh.....wxyzabc
So everything is shifted up 3, but the top three digits are put on the right.
How can this be done neatly.
Also I need the reverse operation, so if I start with
abcdefgh....wxyz
It shifts the other way
xyzabcdefgh....w
This is all done in the 30 digit area. All bits outside the 30 digit area remain 0.
This all has to be done with one eye on the fact that javascript only credibly recognises numbers up to 52/53 bits.
What I have so far but it looks yuck:
var digits = 30;
var shift = 3;
var value = 167596277;
var shiftedValue = (value >> shift) | (value & (Math.pow(2, shift)-1)) << (digits - shift);