[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: c-ldtoastr test failure
From: |
Marc Nieper-Wißkirchen |
Subject: |
Re: c-ldtoastr test failure |
Date: |
Mon, 10 Aug 2020 15:46:48 +0200 |
Hi Bruno,
thanks for catching that. The proposed change is perfect. Actually, I
had made that fix in my local code as well so I am wondering why it
didn't make itself into the patch I sent you.
Best,
Marc
Am Mo., 10. Aug. 2020 um 08:55 Uhr schrieb Bruno Haible <bruno@clisp.org>:
>
> Hi Marc,
>
> On a Linux/x86_64 system, the c-ldtoastr uni test fails.
>
> How to reproduce:
> $ ./gnulib-tool --test --single-configure c-ldtoastr
>
> The test fails like this:
> ../../gltests/test-c-ldtoastr.c:54: assertion '!strcmp (buf, "0.1")' failed
>
> In the debugger, I see that where the code expects a result "0.1",
> the actual result is "0.10000000000000000555".
>
> This rounding error is not caused by the library code for binary to decimal
> conversion, because you can see that the number in its full glory in the
> debugger:
>
> (gdb) step
> c_ldtoastr (buf=buf@entry=0x7fffffffd670 "1,", bufsize=bufsize@entry=40,
> flags=flags@entry=0, width=width@entry=0,
> x=0.1000000000000000055511151231257827) at ../../gllib/ftoastr.c:113
>
>
> Here's a suggested fix. OK to push?
>
>
> 2020-08-09 Bruno Haible <bruno@clisp.org>
>
> c-ldtoastr tests: Fix test failure.
> * tests/test-c-ldtoastr.c (main): Support platforms where 'long
> double'
> is longer than 'double'.
>
> diff --git a/tests/test-c-ldtoastr.c b/tests/test-c-ldtoastr.c
> index 140f0c6..7e38422 100644
> --- a/tests/test-c-ldtoastr.c
> +++ b/tests/test-c-ldtoastr.c
> @@ -50,7 +50,7 @@ main (int argc, char *argv[])
> {
> char buf[DBL_BUFSIZE_BOUND];
>
> - c_ldtoastr (buf, sizeof buf, 0, 0, 0.1);
> + c_ldtoastr (buf, sizeof buf, 0, 0, 0.1L);
> ASSERT (!strcmp (buf, "0.1"));
> }
>
>