public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
@ 2015-07-09  7:52 dhekir at gmail dot com
  2015-07-09 15:54 ` [Bug math/18647] " dhekir at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dhekir at gmail dot com @ 2015-07-09  7:52 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18647

            Bug ID: 18647
           Summary: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: dhekir at gmail dot com
  Target Milestone: ---

powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf.

Tested with glibc 2.19 (Ubuntu 14.04) and also compiled from git (release 2.21,
as indicated in http://www.gnu.org/software/libc/download.html).

Also tested with musl, which returns the correct value in this case.

pow() also returns the correct value (in both libraries).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/18647] powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
  2015-07-09  7:52 [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf dhekir at gmail dot com
@ 2015-07-09 15:54 ` dhekir at gmail dot com
  2015-07-17  8:07 ` dhekir at gmail dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dhekir at gmail dot com @ 2015-07-09 15:54 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18647

--- Comment #1 from dhekir at gmail dot com ---
Some extra information:

- powf(x,y) returns 0 instead of +inf for approximately all of these values:
  -0x1.000002p0 <= x <= -0x1.00000ep0
         0x1p27  < y <  +inf

- Although it only happens with powf() and in a very narrow range, one reason
why it is especially troublesome is that, for x < -1 and a large even y, the
result should be in the interval [1,+inf], and so the zero introduces a
discontinuity. And introducing zeros where none are expected could lead to some
(unlikely) division by zero errors...

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/18647] powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
  2015-07-09  7:52 [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf dhekir at gmail dot com
  2015-07-09 15:54 ` [Bug math/18647] " dhekir at gmail dot com
@ 2015-07-17  8:07 ` dhekir at gmail dot com
  2015-08-05 15:03 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dhekir at gmail dot com @ 2015-07-17  8:07 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18647

--- Comment #2 from dhekir at gmail dot com ---
Also, it only occurs with the 64-bit version of the library. For instance, the
following program prints "f = 0|0" when compiled with `gcc t.c -lm` but "f =
inf|inf" when compiled with `gcc -m32 t.c -lm`:


```
#include <stdio.h>
#include <math.h>

int main() {
  float f = powf(-0x1.000002p0, 0x1p30);
  printf("f = %g|%a\n", f, f);
  return 0;
}
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/18647] powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
  2015-07-09  7:52 [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf dhekir at gmail dot com
  2015-07-09 15:54 ` [Bug math/18647] " dhekir at gmail dot com
  2015-07-17  8:07 ` dhekir at gmail dot com
@ 2015-08-05 15:03 ` cvs-commit at gcc dot gnu.org
  2015-08-05 15:04 ` jsm28 at gcc dot gnu.org
  2015-08-06 11:05 ` hjl.tools at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-05 15:03 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18647

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  cf36e5034fa8ed5d44036bce09a55a7f00d19252 (commit)
      from  2aa6c8af26e65695e9daf382a6e508574a30cdf2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cf36e5034fa8ed5d44036bce09a55a7f00d19252

commit cf36e5034fa8ed5d44036bce09a55a7f00d19252
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Aug 5 15:01:58 2015 +0000

    Fix powf (close to -1, large) (bug 18647).

    The flt-32 implementation of powf wrongly uses x-1 instead of |x|-1
    when computing log (x) for the case where |x| is close to 1 and y is
    large.  This patch fixes the logic accordingly.  Relevant tests
    existed for x close to 1, and corresponding tests are added for x
    close to -1, as well as for some new variant cases.

    Tested for x86_64 and x86.

        [BZ #18647]
        * sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): For large y
        and |x| close to 1, use absolute value of x when computing log.
        * math/auto-libm-test-in: Add more tests of pow.
        * math/auto-libm-test-out: Regenerated.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                       |    8 +
 NEWS                            |    2 +-
 math/auto-libm-test-in          |   40 +
 math/auto-libm-test-out         | 5611 +++++++++++++++++++++++++++++++++++++++
 sysdeps/ieee754/flt-32/e_powf.c |    2 +-
 5 files changed, 5661 insertions(+), 2 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/18647] powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
  2015-07-09  7:52 [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf dhekir at gmail dot com
                   ` (2 preceding siblings ...)
  2015-08-05 15:03 ` cvs-commit at gcc dot gnu.org
@ 2015-08-05 15:04 ` jsm28 at gcc dot gnu.org
  2015-08-06 11:05 ` hjl.tools at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-08-05 15:04 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18647

Joseph Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Joseph Myers <jsm28 at gcc dot gnu.org> ---
Fixed for 2.23.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/18647] powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf
  2015-07-09  7:52 [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf dhekir at gmail dot com
                   ` (3 preceding siblings ...)
  2015-08-05 15:04 ` jsm28 at gcc dot gnu.org
@ 2015-08-06 11:05 ` hjl.tools at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2015-08-06 11:05 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=18647

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |2.23

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-06 11:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-09  7:52 [Bug math/18647] New: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf dhekir at gmail dot com
2015-07-09 15:54 ` [Bug math/18647] " dhekir at gmail dot com
2015-07-17  8:07 ` dhekir at gmail dot com
2015-08-05 15:03 ` cvs-commit at gcc dot gnu.org
2015-08-05 15:04 ` jsm28 at gcc dot gnu.org
2015-08-06 11:05 ` hjl.tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).