From e25ee774aef2ee56c925cfa75e3958fe9637ae32 Mon Sep 17 00:00:00 2001 From: Junekey Jeon Date: Tue, 7 May 2024 00:13:47 -0700 Subject: [PATCH] Small improvements --- include/dragonbox/dragonbox.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/dragonbox/dragonbox.h b/include/dragonbox/dragonbox.h index dcd9e44..d1913f6 100644 --- a/include/dragonbox/dragonbox.h +++ b/include/dragonbox/dragonbox.h @@ -260,6 +260,10 @@ namespace jkj { #endif template using is_integral = JKJ_STD_REPLACEMENT_NAMESPACE::is_integral; + template + using is_signed = JKJ_STD_REPLACEMENT_NAMESPACE::is_signed; + template + using is_unsigned = JKJ_STD_REPLACEMENT_NAMESPACE::is_unsigned; } } @@ -363,12 +367,14 @@ namespace jkj { // assumed to be zeroed. static_assert(detail::value_bits::value >= Format::total_bits, "jkj::dragonbox: insufficient number of bits"); + static_assert(detail::stdr::is_unsigned::value, ""); // ExponentUInt needs to be large enough to hold (unsigned) exponent bits as well as the // (signed) actual exponent. // TODO: static overflow guard against intermediate computations. static_assert(detail::value_bits::value >= Format::exponent_bits + 1, "jkj::dragonbox: insufficient number of bits"); + static_assert(detail::stdr::is_signed::value, ""); using format = Format; using carrier_uint = CarrierUInt; @@ -3419,12 +3425,11 @@ namespace jkj { } else { // r == deltai; compare fractional parts. - auto const x_result = - multiplication_traits_::compute_mul_parity(two_fc - 1, cache, beta); + auto const x_result = multiplication_traits_::compute_mul_parity( + carrier_uint(two_fc - 1), cache, beta); if (!(x_result.parity | - stdr::uint_fast8_t(x_result.is_integer & - interval_type.include_left_endpoint()))) { + (x_result.is_integer & interval_type.include_left_endpoint()))) { break; } }