I am creating a BitSet with a fixed number of bits. In this case the length of my String holding the binary representation is 508 characters long.
So I create BitSet the following way:
BitSet bs = new BitSet(binary.length());
// binary.length() = 508
But looking at the size of bs I always get a size of 512. I can see that there are always 4 Bits with value of 0 appended at the end.
Maybe there is some misunderstanding of the following documentation:
BitSet(int nbits)
Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through nbits-1.
Is it that BitSet always enhances its size so that its size is powers of 2 or why is it larger?