From 003a98318876f5376fe18cc745440ea6ef2f387a Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 18 Nov 2022 15:38:21 -0500 Subject: [PATCH] Simplifying the justification. --- include/fast_float/parse_number.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 0e22afc..bd0ab43 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -81,7 +81,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept { // There might be other ways to prevent compile-time optimizations (e.g., asm). // The value does not need to be std::numeric_limits::min(), any small // value so that 1 + x should round to 1 would do (after accounting for excess - // precision, as in 387). + // precision, as in 387 instructions). static volatile float fmin = std::numeric_limits::min(); float fmini = fmin; // we copy it so that it gets loaded at most once. // @@ -90,19 +90,12 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept { // fmin + 1.0f == 1.0f - fmin. // // FE_UPWARD: - // fmin + 1.0f = 0x1.00001 (1.00001) - // 1.0f - fmin = 0x1 (1) + // fmin + 1.0f > 1 + // 1.0f - fmin == 1 // // FE_DOWNWARD or FE_TOWARDZERO: - // fmin + 1.0f = 0x1 (1) - // 1.0f - fmin = 0x0.999999 (0.999999) - // - // fmin + 1.0f = 0x1 (1) - // 1.0f - fmin = 0x0.999999 (0.999999) - // - // FE_TONEAREST: - // fmin + 1.0f = 0x1 (1) - // 1.0f - fmin = 0x1 (1) + // fmin + 1.0f == 1 + // 1.0f - fmin < 1 // // Note: This may fail to be accurate if fast-math has been // enabled, as rounding conventions may not apply.