Get the number of bytes associate with a packing.
| 38 | |
| 39 | /// Get the number of bytes associate with a packing. |
| 40 | constexpr int32_t GetNumBytes(int32_t num_values, int32_t bit_width) { |
| 41 | const auto num_bits = num_values * bit_width; |
| 42 | if (num_bits % 8 != 0) { |
| 43 | throw std::invalid_argument("Must pack a multiple of 8 bits."); |
| 44 | } |
| 45 | return num_bits / 8; |
| 46 | } |
| 47 | |
| 48 | /// Generate random bytes as packed integers. |
| 49 | std::vector<uint8_t> GenerateRandomPackedValues(int32_t num_values, int32_t bit_width) { |
no outgoing calls
no test coverage detected