Minor fix.

This commit is contained in:
Daniel Lemire 2023-02-06 17:22:11 -05:00
parent 764a064c12
commit 252a1c9dce
2 changed files with 6 additions and 0 deletions

View File

@ -66,6 +66,10 @@ from_chars_result parse_infnan(const char *first, const char *last, T &value) n
* Credit : @mwalcott3
*/
fastfloat_really_inline bool rounds_to_nearest() noexcept {
// https://lemire.me/blog/2020/06/26/gcc-not-nearest/
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
return false;
#endif
// See
// A fast function to check your floating-point rounding mode
// https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/

View File

@ -132,7 +132,9 @@ TEST_CASE("rounds_to_nearest") {
fesetround(FE_TONEAREST);
std::cout << "FE_TONEAREST: fmin + 1.0f = " << iHexAndDec(fmin + 1.0f) << " 1.0f - fmin = " << iHexAndDec(1.0f - fmin) << std::endl;
CHECK(fegetround() == FE_TONEAREST);
#if (FLT_EVAL_METHOD == 1) || (FLT_EVAL_METHOD == 0)
CHECK(fast_float::detail::rounds_to_nearest() == true);
#endif
}
TEST_CASE("parse_zero") {