I want to compare two multiplication methods implemented in Java which use shift operations on big numbers. Thus I need sufficiently large BigIntegers.
Since I want to compare them bit-wise, what would be the best approach to generate BigIntegers with n bits which are fully used in the multiplication operation.
My approach so far is this:
byte[] bits = new byte[bitLength];
BigInteger number = new BigInteger(bits).flipBit(bitLength);
How about this:
In other words, set the bit which is one higher than you want, then subtract one to get a value which uses all the lower bits.