[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libdfp-patches] [PATCH] Fix printing of mantissa near 1.0 in 'f' format



On Mon, 2010-10-04 at 18:11 -0300, Luis Machado wrote:
> Hi,
> 
> This is a fix Andreas did. It's been tested and confirmed to work. I'm
> submitting it to the list for the sake of formality.

...
> 2010-10-04  Andreas Schwab  <schwab@xxxxxxxxxx>
> 
> 	* printf_dfp.c (__printf_dfp): Fix up nd when rounding overflows
> 	beyond first digit.
> ---
>  printf_dfp.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/printf_dfp.c b/printf_dfp.c
> index 05700af..90af8db 100644
> --- a/printf_dfp.c
> +++ b/printf_dfp.c
> @@ -697,8 +697,8 @@ __printf_dfp (FILE *fp,
>  	  }
> 
>  	while (digits[--index] == '9') digits[index] = '0';
> -	  digits[index]++;
> -	if (index < n) { n--; }
> +	digits[index]++;
> +	if (index < n) { n--; nd++; }
>        } while (0);
>      } /* Done rounding.  */

This has been committed upstream along with a fix to tests/test-printf.c
which adds the failure case and demonstrates that the code is fixed with
the patch.

Ryan