From facd00f02c9716449784ed02636dacf00577d991 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Mon, 19 Jun 2023 16:14:59 +0200 Subject: [PATCH] Add precision argument --- include/boost/charconv/detail/ryu/ryu_generic_128.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/boost/charconv/detail/ryu/ryu_generic_128.hpp b/include/boost/charconv/detail/ryu/ryu_generic_128.hpp index a677ec7..79008af 100644 --- a/include/boost/charconv/detail/ryu/ryu_generic_128.hpp +++ b/include/boost/charconv/detail/ryu/ryu_generic_128.hpp @@ -413,7 +413,7 @@ static inline int generic_to_chars(const struct floating_decimal_128 v, char* re return index; } -static inline int generic_to_chars_fixed(const struct floating_decimal_128 v, char* result, const ptrdiff_t result_size, int) noexcept +static inline int generic_to_chars_fixed(const struct floating_decimal_128 v, char* result, const ptrdiff_t result_size, int precision) noexcept { if (v.exponent == fd128_exceptional_exponent) { @@ -469,6 +469,12 @@ static inline int generic_to_chars_fixed(const struct floating_decimal_128 v, ch current_len = -v.exponent + 2; } + if (current_len < precision) + { + memset(result + current_len, '0', precision - current_len); + current_len = precision; + } + return current_len; }