mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Minor cleaning.
This commit is contained in:
parent
1b775cd9a7
commit
e79741ede2
@ -241,6 +241,10 @@ fastfloat_really_inline decimal parse_decimal(const char *p, const char *pend) n
|
|||||||
answer.truncated = true;
|
answer.truncated = true;
|
||||||
answer.num_digits = max_digits;
|
answer.num_digits = max_digits;
|
||||||
}
|
}
|
||||||
|
// In very rare cases, we may have fewer than 19 digits, we want to be able to reliably
|
||||||
|
// assume that all digits up to max_digit_without_overflow have been initialized.
|
||||||
|
for(uint32_t i = answer.num_digits; i < max_digit_without_overflow; i++) { answer.digits[i] = 0; }
|
||||||
|
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
} // namespace fast_float
|
} // namespace fast_float
|
||||||
|
|||||||
@ -149,9 +149,10 @@ struct decimal {
|
|||||||
// Moves are allowed:
|
// Moves are allowed:
|
||||||
decimal(decimal &&) = default;
|
decimal(decimal &&) = default;
|
||||||
decimal &operator=(decimal &&other) = default;
|
decimal &operator=(decimal &&other) = default;
|
||||||
// Generates a mantissa by truncating to 19 digits; this function assumes
|
// Generates a mantissa by truncating to 19 digits.
|
||||||
// that num_digits >= 19 (the caller is responsible for the check).
|
|
||||||
// This function should be reasonably fast.
|
// This function should be reasonably fast.
|
||||||
|
// Note that the user is responsible to ensure that digits are
|
||||||
|
// initialized to zero when there are fewer than 19.
|
||||||
inline uint64_t to_truncated_mantissa() {
|
inline uint64_t to_truncated_mantissa() {
|
||||||
uint64_t val;
|
uint64_t val;
|
||||||
// 8 first digits
|
// 8 first digits
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user