determine if any non-zero digits were truncated. all characters must be valid digits.
| 2629 | // determine if any non-zero digits were truncated. |
| 2630 | // all characters must be valid digits. |
| 2631 | fastfloat_really_inline bool is_truncated(const char* first, const char* last) noexcept { |
| 2632 | // do 8-bit optimizations, can just compare to 8 literal 0s. |
| 2633 | uint64_t val; |
| 2634 | while (std::distance(first, last) >= 8) { |
| 2635 | ::memcpy(&val, first, sizeof(uint64_t)); |
| 2636 | if (val != 0x3030303030303030) { |
| 2637 | return true; |
| 2638 | } |
| 2639 | first += 8; |
| 2640 | } |
| 2641 | while (first != last) { |
| 2642 | if (*first != '0') { |
| 2643 | return true; |
| 2644 | } |
| 2645 | first++; |
| 2646 | } |
| 2647 | return false; |
| 2648 | } |
| 2649 | |
| 2650 | fastfloat_really_inline bool is_truncated(byte_span s) noexcept { |
| 2651 | return is_truncated(s.ptr, s.ptr + s.len()); |