Skip to content
Discussion options

You must be logged in to vote

Thanks for the feedback. The Boolean array packing does need to be explained more explicitly. I'll try to update the spec soon, but here's some example C++ for the packing:

const auto num_bytes = (value.size() + 7) / 8;
         std::vector<uint8_t> bytes(num_bytes);
         for (size_t byte_i{}, i{}; byte_i < num_bytes; ++byte_i) {
            for (size_t bit_i = 0; bit_i < 8 && i < value.size(); ++bit_i, ++i) {
               bytes[byte_i] |= uint8_t(value[i]) << uint8_t(bit_i);
            }
         }

So, for each byte, bit 0 is the LSB (index 0). 0b00000001 would be true in the 0 index of the bit array. 0b00000010 would be true in the 1 index of the array.

Bits are then padded to th…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by justDeeevin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants