| 648 | /// \result the output length of the array |
| 649 | template <size_t N> |
| 650 | static int64_t FillInArray(const std::array<uint64_t, N>& value_array, |
| 651 | uint32_t* result_array) { |
| 652 | const auto value_array_le = bit_util::little_endian::Make(value_array); |
| 653 | int64_t next_index = 0; |
| 654 | // 1st loop to find out 1st non-negative value in input |
| 655 | int64_t i = N - 1; |
| 656 | for (; i >= 0; i--) { |
| 657 | if (value_array_le[i] != 0) { |
| 658 | if (value_array_le[i] <= std::numeric_limits<uint32_t>::max()) { |
| 659 | result_array[next_index++] = static_cast<uint32_t>(value_array_le[i]); |
| 660 | i--; |
| 661 | } |
| 662 | break; |
| 663 | } |
| 664 | } |
| 665 | // 2nd loop to fill in the rest of the array. |
| 666 | for (int64_t j = i; j >= 0; j--) { |
| 667 | result_array[next_index++] = static_cast<uint32_t>(value_array_le[j] >> 32); |
| 668 | result_array[next_index++] = static_cast<uint32_t>(value_array_le[j]); |
| 669 | } |
| 670 | return next_index; |
| 671 | } |
| 672 | |
| 673 | /// Expands the given value into a big endian array of ints so that we can work on |
| 674 | /// it. The array will be converted to an absolute value and the was_negative |
no test coverage detected