mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 08:46:49 +08:00
Merge pull request #333 from toughengineer/made_function_non-template
Made function non-template
This commit is contained in:
commit
83a4f696d7
@ -38,11 +38,8 @@ constexpr static uint64_t powers_of_ten_uint64[] = {1UL,
|
|||||||
// this algorithm is not even close to optimized, but it has no practical
|
// this algorithm is not even close to optimized, but it has no practical
|
||||||
// effect on performance: in order to have a faster algorithm, we'd need
|
// effect on performance: in order to have a faster algorithm, we'd need
|
||||||
// to slow down performance for faster algorithms, and this is still fast.
|
// to slow down performance for faster algorithms, and this is still fast.
|
||||||
template <typename UC>
|
|
||||||
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int32_t
|
fastfloat_really_inline FASTFLOAT_CONSTEXPR14 int32_t
|
||||||
scientific_exponent(parsed_number_string_t<UC> &num) noexcept {
|
scientific_exponent(uint64_t mantissa, int32_t exponent) noexcept {
|
||||||
uint64_t mantissa = num.mantissa;
|
|
||||||
int32_t exponent = int32_t(num.exponent);
|
|
||||||
while (mantissa >= 10000) {
|
while (mantissa >= 10000) {
|
||||||
mantissa /= 10000;
|
mantissa /= 10000;
|
||||||
exponent += 4;
|
exponent += 4;
|
||||||
@ -398,7 +395,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp(
|
|||||||
FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp)));
|
FASTFLOAT_ASSERT(real_digits.pow2(uint32_t(-pow2_exp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare digits, and use it to director rounding
|
// compare digits, and use it to direct rounding
|
||||||
int ord = real_digits.compare(theor_digits);
|
int ord = real_digits.compare(theor_digits);
|
||||||
adjusted_mantissa answer = am;
|
adjusted_mantissa answer = am;
|
||||||
round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
|
round<T>(answer, [ord](adjusted_mantissa &a, int32_t shift) {
|
||||||
@ -419,7 +416,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp(
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the significant digits as a big integer to unambiguously round the
|
// parse the significant digits as a big integer to unambiguously round
|
||||||
// the significant digits. here, we are trying to determine how to round
|
// the significant digits. here, we are trying to determine how to round
|
||||||
// an extended float representation close to `b+h`, halfway between `b`
|
// an extended float representation close to `b+h`, halfway between `b`
|
||||||
// (the float rounded-down) and `b+u`, the next positive float. this
|
// (the float rounded-down) and `b+u`, the next positive float. this
|
||||||
@ -438,7 +435,8 @@ digit_comp(parsed_number_string_t<UC> &num, adjusted_mantissa am) noexcept {
|
|||||||
// remove the invalid exponent bias
|
// remove the invalid exponent bias
|
||||||
am.power2 -= invalid_am_bias;
|
am.power2 -= invalid_am_bias;
|
||||||
|
|
||||||
int32_t sci_exp = scientific_exponent(num);
|
int32_t sci_exp =
|
||||||
|
scientific_exponent(num.mantissa, static_cast<int32_t>(num.exponent));
|
||||||
size_t max_digits = binary_format<T>::max_digits();
|
size_t max_digits = binary_format<T>::max_digits();
|
||||||
size_t digits = 0;
|
size_t digits = 0;
|
||||||
bigint bigmant;
|
bigint bigmant;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user