Skip to content

Commit

Permalink
Fix general chars format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Oct 18, 2024
1 parent f3e2c9d commit 07c59a4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions include/boost/charconv/detail/ryu/ryu_generic_128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ static inline int generic_to_chars_fixed(const struct floating_decimal_128 v, ch
++current_len;
if (current_len - shift_width > precision)
{
current_len = static_cast<int>(shift_width) + precision;
if (precision > 0)
{
current_len = static_cast<int>(shift_width) + precision;
}

precision = 0;
// Since we wrote additional characters into the buffer we need to add a null terminator,
// so they are not read
Expand Down Expand Up @@ -528,7 +532,17 @@ static inline int generic_to_chars(const struct floating_decimal_128 v, char* re
const int64_t exp = v.exponent + static_cast<int64_t>(olength);
if (std::abs(exp) <= olength)
{
return generic_to_chars_fixed(v, result, result_size, precision);
auto ptr = generic_to_chars_fixed(v, result, result_size, precision);
if (result[ptr - 1] == '0')
{
--ptr;
while (result[ptr] == '0')
{
--ptr;
}
++ptr;
}
return ptr;
}
}

Expand Down

0 comments on commit 07c59a4

Please sign in to comment.