mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
added additional macro FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED for performance improve.
This commit is contained in:
parent
17ffdffdd9
commit
c99930b2a0
@ -75,6 +75,7 @@ from_chars_result_t<UC>
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED
|
||||||
/**
|
/**
|
||||||
* Returns true if the floating-pointing rounding mode is to 'nearest'.
|
* Returns true if the floating-pointing rounding mode is to 'nearest'.
|
||||||
* It is the default on most system. This function is meant to be inexpensive.
|
* It is the default on most system. This function is meant to be inexpensive.
|
||||||
@ -139,6 +140,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept {
|
|||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
@ -226,7 +228,9 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
// We could check it first (before the previous branch), but
|
// We could check it first (before the previous branch), but
|
||||||
// there might be performance advantages at having the check
|
// there might be performance advantages at having the check
|
||||||
// be last.
|
// be last.
|
||||||
|
#ifndef FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED
|
||||||
if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
|
if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
|
||||||
|
#endif
|
||||||
// We have that fegetround() == FE_TONEAREST.
|
// We have that fegetround() == FE_TONEAREST.
|
||||||
// Next is Clinger's fast path.
|
// Next is Clinger's fast path.
|
||||||
if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
|
if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
|
||||||
@ -243,6 +247,7 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
#endif
|
#endif
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
#ifndef FASTFLOAT_ONLY_ROUNDS_TO_NEAREST_SUPPORTED
|
||||||
} else {
|
} else {
|
||||||
// We do not have that fegetround() == FE_TONEAREST.
|
// We do not have that fegetround() == FE_TONEAREST.
|
||||||
// Next is a modified Clinger's fast path, inspired by Jakub Jelínek's
|
// Next is a modified Clinger's fast path, inspired by Jakub Jelínek's
|
||||||
@ -271,6 +276,7 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
adjusted_mantissa am =
|
adjusted_mantissa am =
|
||||||
compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
|
compute_float<binary_format<T>>(pns.exponent, pns.mantissa);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user