Fixing a minor logical error.

This commit is contained in:
Daniel Lemire 2020-10-29 16:42:50 -04:00
parent ac87437588
commit 562d4f4f58
1 changed files with 4 additions and 2 deletions

View File

@ -76,10 +76,11 @@ decimal parse_decimal(const char *&p) noexcept {
}
while (is_integer(*p)) {
if (answer.num_digits + 1 < max_digits) {
answer.digits[answer.num_digits++] = uint8_t(*p - '0');
answer.digits[answer.num_digits] = uint8_t(*p - '0');
} else {
answer.truncated = true;
}
answer.num_digits++;
++p;
}
const char *first_after_period{};
@ -95,10 +96,11 @@ decimal parse_decimal(const char *&p) noexcept {
}
while (is_integer(*p)) {
if (answer.num_digits + 1 < max_digits) {
answer.digits[answer.num_digits++] = uint8_t(*p - '0');
answer.digits[answer.num_digits] = uint8_t(*p - '0');
} else {
answer.truncated = true;
}
answer.num_digits++;
++p;
}
answer.decimal_point = int32_t(first_after_period - p);