toBitString

Returns all bits as they are accessible by the global bit index (i.e. after wrapping this ByteArray into a BitSet)

Note that this representation conflicts with the usual binary representation of a byte array for the following reason:

Printing a byte array usually shows the MSByte at the right-most position, but each byte's MSBit at a byte's individual left-most position, leading to bit and byte indices running in opposing directions.

The string representation returned by this function can simply be interpreted as a list of boolean values accessible by a monotonic index running in one direction.

See the following illustration of memory layout vs. bit string index and the resulting string:

┌──────────────────────────────┐
│ │
│ │ Addr: 2
│    0 0 0 0 1 1 0 1    │
│   ◄─23─22─21─20─19─18─17─16─┐ │
│ │ │
├─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│─ ┤
│ │ │
│ ┌─────────────────────────┘ │ Addr: 1
│ │ 1 0 0 0 1 0 0 0 │
│ └─15─14─12─12─11─10──9──8─┐ │
│ │ │
├─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│─ ┤
│ │ │
│ ┌─────────────────────────┘ │ Addr: 0
│ │ 1 0 1 1 0 1 1 1 │
│ └──7──6──5──4──3──2──1──0──────index─◄─
│ │
└──────────────────────────────┘

This leads to the following bit string: 11101101000100011011