public int byteLength()
    {
        // per https://docs.oracle.com/javase/8/docs/api/java/util/BitSet.html#toByteArray--
        return (bitSet.length() + 7) / 8;
    }
@Test
    public static void testByteLength()
    {
        for (int length : new int[] {8, 800}) {
            Bitmap bitmap = new Bitmap(length);
            for (int i = 0; i < length; i++) {
                bitmap.setBit(i, true);
                assertEquals(bitmap.byteLength(), bitmap.toBytes().length);
            }
        }
    }