| 3370 | // parse the significant digits into a big integer |
| 3371 | template <typename UC> |
| 3372 | inline FASTFLOAT_CONSTEXPR20 void |
| 3373 | parse_mantissa(bigint &result, parsed_number_string_t<UC> &num, |
| 3374 | size_t max_digits, size_t &digits) noexcept { |
| 3375 | // try to minimize the number of big integer and scalar multiplication. |
| 3376 | // therefore, try to parse 8 digits at a time, and multiply by the largest |
| 3377 | // scalar value (9 or 19 digits) for each step. |
| 3378 | size_t counter = 0; |
| 3379 | digits = 0; |
| 3380 | limb value = 0; |
| 3381 | #ifdef FASTFLOAT_64BIT_LIMB |
| 3382 | size_t step = 19; |
| 3383 | #else |
| 3384 | size_t step = 9; |
| 3385 | #endif |
| 3386 | |
| 3387 | // process all integer digits. |
| 3388 | UC const *p = num.integer.ptr; |
| 3389 | UC const *pend = p + num.integer.len(); |
| 3390 | skip_zeros(p, pend); |
| 3391 | // process all digits, in increments of step per loop |
| 3392 | while (p != pend) { |
| 3393 | while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && |
| 3394 | (max_digits - digits >= 8)) { |
| 3395 | parse_eight_digits(p, value, counter, digits); |
| 3396 | } |
| 3397 | while (counter < step && p != pend && digits < max_digits) { |
| 3398 | parse_one_digit(p, value, counter, digits); |
| 3399 | } |
| 3400 | if (digits == max_digits) { |
| 3401 | // add the temporary value, then check if we've truncated any digits |
| 3402 | add_native(result, limb(powers_of_ten_uint64[counter]), value); |
| 3403 | bool truncated = is_truncated(p, pend); |
| 3404 | if (num.fraction.ptr != nullptr) { |
| 3405 | truncated |= is_truncated(num.fraction); |
| 3406 | } |
| 3407 | if (truncated) { |
| 3408 | round_up_bigint(result, digits); |
| 3409 | } |
| 3410 | return; |
| 3411 | } else { |
| 3412 | add_native(result, limb(powers_of_ten_uint64[counter]), value); |
| 3413 | counter = 0; |
| 3414 | value = 0; |
| 3415 | } |
| 3416 | } |
| 3417 | |
| 3418 | // add our fraction digits, if they're available. |
| 3419 | if (num.fraction.ptr != nullptr) { |
| 3420 | p = num.fraction.ptr; |
| 3421 | pend = p + num.fraction.len(); |
| 3422 | if (digits == 0) { |
| 3423 | skip_zeros(p, pend); |
| 3424 | } |
| 3425 | // process all digits, in increments of step per loop |
| 3426 | while (p != pend) { |
| 3427 | while ((std::distance(p, pend) >= 8) && (step - counter >= 8) && |
| 3428 | (max_digits - digits >= 8)) { |
| 3429 | parse_eight_digits(p, value, counter, digits); |
no test coverage detected