From f1bd6f773130c797bd0f73e262e14f0bcba5fc44 Mon Sep 17 00:00:00 2001 From: Junekey Jeon Date: Tue, 8 Feb 2022 18:23:53 -0800 Subject: [PATCH] Check r < deltai first, because that is the major branch chosen for short inputs --- include/fmt/format-inl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 9912dc1c..eba27f46 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -2049,15 +2049,15 @@ template decimal_fp to_decimal(T x) noexcept { uint32_t r = static_cast(z_mul.result - float_info::big_divisor * ret_value.significand); - if (r > deltai) { - goto small_divisor_case_label; - } else if (r < deltai) { + if (r < deltai) { // Exclude the right endpoint if necessary. if (r == 0 && z_mul.is_integer && !include_right_endpoint) { --ret_value.significand; r = float_info::big_divisor; goto small_divisor_case_label; } + } else if (r > deltai) { + goto small_divisor_case_label; } else { // r == deltai; compare fractional parts. const carrier_uint two_fl = two_fc - 1;