@@ -462,8 +462,6 @@ constexpr uint32_t neg100 = (1 << 16) - 100;
462462constexpr int div10_exp = 10 ;
463463constexpr uint32_t div10_sig = (1 << div10_exp) / 10 + 1 ;
464464constexpr uint32_t neg10 = (1 << 8 ) - 10 ;
465- // (1 << 63) / 5 == (1 << 64) / 10 without an intermediate int128.
466- constexpr uint64_t div10_sig64 = (1ull << 63 ) / 5 + 1 ;
467465
468466constexpr uint64_t zeros = 0x0101010101010101u * ' 0' ;
469467
@@ -612,17 +610,16 @@ auto write_significand17(char* buffer, uint64_t value, bool has17digits,
612610 buffer += 16 - ((zeroes != 0 ? clz (zeroes) : 64 ) >> 2 );
613611 return buffer - int (buffer - start == 1 );
614612#elif ZMIJ_USE_SSE
615- uint64_t digits_16 = value_div10;
616- uint32_t last_digit = value - digits_16 * 10 ;
613+ uint32_t last_digit = value - value_div10 * 10 ;
617614
618615 // We always write 17 digits into the buffer, but the first one can be zero.
619616 // buffer points to the second place in the output buffer to allow for the
620617 // insertion of the decimal point, so we can use the first place as scratch.
621618 buffer += has17digits;
622619 buffer[16 ] = char (last_digit + ' 0' );
623620
624- uint32_t abcdefgh = digits_16 / uint64_t (1e8 );
625- uint32_t ijklmnop = digits_16 % uint64_t (1e8 );
621+ uint32_t abcdefgh = value_div10 / uint64_t (1e8 );
622+ uint32_t ijklmnop = value_div10 % uint64_t (1e8 );
626623
627624 alignas (64 ) static constexpr struct {
628625 __m128i div10k = splat64(div10k_sig);
@@ -827,6 +824,8 @@ ZMIJ_INLINE auto to_decimal_normal(UInt bin_sig, int64_t raw_exp,
827824
828825 // An optimization of integral % 10 by Dougall Johnson.
829826 // Relies on range calculation: (max_bin_sig << max_exp_shift) * max_u128.
827+ // (1 << 63) / 5 == (1 << 64) / 10 without an intermediate int128.
828+ constexpr uint64_t div10_sig64 = (1ull << 63 ) / 5 + 1 ;
830829 long long div10 =
831830 ZMIJ_USE_INT128 ? umul128_hi64 (integral, div10_sig64) : integral / 10 ;
832831 uint64_t digit = integral - div10 * 10 ;
0 commit comments