The
BitArray
stores the bits in a series of
int
values, starting with the least significant bit.
Passing in
false, false, true, true, false, false, false, false
is equivalent to
0b0000_1100
,
not 0b0011_0000
.
The integer value you have stored in your
newBitArray
is
0b0010_1110_0000_1100
, which is
0x2E0C
.
But because you're pulling out a single byte at a time, you're getting them in reverse -
0x0C
, followed by
0x2E
.
It's not entirely clear what you're trying to achieve, but you might have better luck with
the BigInteger class[
^].