public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/14034] New: acos (-1.0) gives -pi in round-downwards mode on x86
@ 2012-04-29 14:43 jsm28 at gcc dot gnu.org
  2012-04-29 17:32 ` [Bug math/14034] " bugdal at aerifal dot cx
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-04-29 14:43 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14034

             Bug #: 14034
           Summary: acos (-1.0) gives -pi in round-downwards mode on x86
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: unassigned@sourceware.org
        ReportedBy: jsm28@gcc.gnu.org
    Classification: Unclassified


This was discussed in bug 13942, but is really a separate issue:

On x86, acosf (-1.0f), acos (-1.0) and acosl (-1.0L) all give -pi instead of pi
in round-downwards mode, although the result is specified by ISO C to be in the
range [0, pi].  The same applies to acosl (-1.0L) on x86_64.  I'm testing a
patch for this.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug math/14034] acos (-1.0) gives -pi in round-downwards mode on x86
  2012-04-29 14:43 [Bug math/14034] New: acos (-1.0) gives -pi in round-downwards mode on x86 jsm28 at gcc dot gnu.org
@ 2012-04-29 17:32 ` bugdal at aerifal dot cx
  2012-04-30  9:42 ` jsm28 at gcc dot gnu.org
  2014-06-25 11:11 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: bugdal at aerifal dot cx @ 2012-04-29 17:32 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14034

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> 2012-04-29 17:32:06 UTC ---
One quick (but probably wrong; see below) solution I can think of is adding a
single fabs instruction just before return.

With that said, the value of -π returned by glibc's acos(-1) in
downward-rounding mode also differs from the value of -π obtained by -acos(1),
with a difference of 1ulp. What's significant (and probably bad) about this is
that the value is actually less than -π (the actual value), and thus if you
just take the absolute value, you get a result that's greater than π, which
would be rather unexpected in downward-rounding mode. It's within 1ulp so it
may technically be conformant, but it seems very bad.

On the other hand, inserting the fabs instruction just after the fsqrt
instruction (where the only thing it can do is convert -0 to +0) seems to work,
and the value I get trying it is the correctly-rounded representation of π.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug math/14034] acos (-1.0) gives -pi in round-downwards mode on x86
  2012-04-29 14:43 [Bug math/14034] New: acos (-1.0) gives -pi in round-downwards mode on x86 jsm28 at gcc dot gnu.org
  2012-04-29 17:32 ` [Bug math/14034] " bugdal at aerifal dot cx
@ 2012-04-30  9:42 ` jsm28 at gcc dot gnu.org
  2014-06-25 11:11 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-04-30  9:42 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14034

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

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

--- Comment #2 from Joseph Myers <jsm28 at gcc dot gnu.org> 2012-04-30 09:42:01 UTC ---
Fixed by:

commit 5ba3cc691c856e5c67a7d4cd4713f20a79f7ba81
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Mon Apr 30 09:38:06 2012 +0000

    Fix acos (-1) in round-downwards mode on x86 (bug 14034).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug math/14034] acos (-1.0) gives -pi in round-downwards mode on x86
  2012-04-29 14:43 [Bug math/14034] New: acos (-1.0) gives -pi in round-downwards mode on x86 jsm28 at gcc dot gnu.org
  2012-04-29 17:32 ` [Bug math/14034] " bugdal at aerifal dot cx
  2012-04-30  9:42 ` jsm28 at gcc dot gnu.org
@ 2014-06-25 11:11 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-25 11:11 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

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


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

end of thread, other threads:[~2014-06-25 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-29 14:43 [Bug math/14034] New: acos (-1.0) gives -pi in round-downwards mode on x86 jsm28 at gcc dot gnu.org
2012-04-29 17:32 ` [Bug math/14034] " bugdal at aerifal dot cx
2012-04-30  9:42 ` jsm28 at gcc dot gnu.org
2014-06-25 11:11 ` fweimer at redhat 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).