Skip to content

Commit 045ba35

Browse files
committed
Address review nits 2025-01-28
1 parent 97c2a2a commit 045ba35

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

libc/src/stdio/printf_core/float_dec_converter_limited.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ DigitsOutput decimal_digits(DigitsInput input, int precision, bool e_mode) {
220220
// Convert the mantissa into a DyadicFloat, making sure it has the right
221221
// sign, so that directed rounding will go in the right direction, if
222222
// enabled.
223-
//
224-
// (The fixed -127 adjustment on the exponent is because input.mantissa is a
225-
// UInt128, and the leading 1 bit has been aligned to the top of it.)
226-
fputil::DyadicFloat<DF_BITS> flt_mantissa(input.sign, input.exponent - 127,
227-
input.mantissa);
223+
fputil::DyadicFloat<DF_BITS> flt_mantissa(
224+
input.sign,
225+
input.exponent -
226+
(cpp::numeric_limits<decltype(input.mantissa)>::digits - 1),
227+
input.mantissa);
228228

229229
// Divide or multiply, depending on whether log10_low_digit was positive
230230
// or negative.
@@ -362,7 +362,8 @@ DigitsOutput decimal_digits(DigitsInput input, int precision, bool e_mode) {
362362
// we made it from and doing the decimal conversion all over again.)
363363
for (size_t i = output.ndigits; i-- > 0;) {
364364
if (output.digits[i] != '9') {
365-
output.digits[i]++;
365+
output.digits[i] = internal::int_to_b36_char(
366+
internal::b36_char_to_int(output.digits[i]) + 1);
366367
break;
367368
} else {
368369
output.digits[i] = '0';

0 commit comments

Comments
 (0)