[REQUEST] BigInteger::rotate


It looks as though BigInteger does the work of std::bitset

Both are lacking rotateLeft and rotateRight methods. e.g. X << k + X >> (X.numBits()-k)

I feel that anything supporting bit-shifting should also support bit-rotating!


PS https://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation <-- just found the best ever bit-twiddling hack!


I believe this doesn't really make sense for BigInteger: BigInteger simulates an integer which has an "infinite" number of bits, i.e. there is no numBits method. BigInteger will always increase it's size depending on the highest bit set. So there is no defined way to rotate a value of "1" to the left. Where does that lowest significant bit go? It would need to go to an inifinitely high position.


That makes total sense.

 I was considering it as a replacement for std::bitset<k> but it is variable length of course!

 Wasn't thinking clearly..