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

Bug#727841: marked as done (powl() inaccurate but only at runtime)



Your message dated Sat, 22 Feb 2014 23:23:22 +0100
with message-id <20140222222322.GA15731@volta.rr44.fr>
and subject line Re: Bug#727841: powl() inaccurate but only at runtime
has caused the Debian Bug report #727841,
regarding powl() inaccurate but only at runtime
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
727841: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=727841
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libc6
Version: 2.13-38
Severity: normal

On amd64, powl() is generating inaccurate results when called at runtime,
but if a call to it gets constant-folded at compile time (by gcc 4.7)
then the constant-folded result is much more accurate.

$ cat t0.c
#include <math.h>
#include <stdio.h>
int main(void) {
    int c = getchar();
    printf("%.16La\n", powl((long double)c, -298.0L));
    printf("%.16La\n", powl(10.0L, -298.0L));
    return 0;
}
$ gcc t0.c -lm
$ echo | ./a.out
0x8.5f0468293f0ebc30p-993
0x8.5f0468293f0eb4e0p-993

The second of the two values emitted, the one resulting from constant
folding in gcc, is actually the closest long double value available
to the unrepresentable 10**-298.  The first value emitted, resulting
from a runtime call to powl(), is far less accurate.  The difference,
117 ulp, cannot be accounted for by the use of different rounding modes:
there must be actual different algorithms in use.

So (a) libc's powl() is inaccurate; and (b) gcc's constant folding on
powl() doesn't accurately simulate its runtime behaviour.  I think these
are both bugs, but fixing the first will presumably fix the second too,
so for now I'm only reporting this against libc.

Relevant package versions:

libc6:amd64     2.13-38
libc6-dbg:amd64 2.13-38
libc6-dev:amd64 2.13-38
libc6-dev-i386  2.13-38
libc6-i386      2.13-38
libc6-pic:amd64 2.13-38
gcc	4:4.7.2-1
gcc-4.7	4.7.2-5
gcc-4.7-base:amd64	4.7.2-5
gcc-4.7-doc	4.7.2-2
gcc-4.7-locales	4.7.2-5
gcc-4.7-multilib	4.7.2-5
gcc-multilib	4:4.7.2-1

-zefram

--- End Message ---
--- Begin Message ---
Version: 2.17-1

On Fri, Nov 08, 2013 at 10:44:58AM -0500, James Cloos wrote:
> [I hit send to soon ... -JimC]
> 
> And glibc 2.17 gets the same result as gcc does.
> 

Yes, the pow() function has been reworked in 2.17 to improve precision.
Unfortunately it became more slow (see bug#718577), but at least it
gives correct results now.

I am therefore marking this bug as closed in version 2.17-1.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

--- End Message ---

Reply to: