public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pdemarco at maplesoft dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug math/14273] New: cosh() returns incorrect results
Date: Thu, 21 Jun 2012 13:25:00 -0000	[thread overview]
Message-ID: <bug-14273-131@http.sourceware.org/bugzilla/> (raw)

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

             Bug #: 14273
           Summary: cosh() returns incorrect results
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: critical
          Priority: P2
         Component: math
        AssignedTo: unassigned@sourceware.org
        ReportedBy: pdemarco@maplesoft.com
    Classification: Unclassified


cosh() returns incorrect results in the most recent version of libm.  
Here is an example:

ubuntu64ma337>> cat test.c
#include <stdio.h>
#include <math.h>

int main(int argv, char *argc[])
        {
        double np = 709.889355812725967;
        printf("%g\n", cosh(709.889355812725967) );
        printf("%g\n", cosh(np) );
        double nm = -709.889355812725967;
        printf("%g\n", cosh(-709.889355812725967) );
        printf("%g\n", cosh(nm) );
        return 0;
        }
ubuntu64ma337>> gcc test.c -lm
ubuntu64ma337>> a.out
1e+308
1e+308
1e+308
inf


The last result is wrong.

I believe this is because of the following change made to glibc 2.15:

* Integrate libm with gcc's -ffinite-math-only option.
   Implemented by Ulrich Drepper.

Note that http://gcc.gnu.org/onlinedocs/gcc-3.3.6/g77/Optimize-Options.html has
this to say about the finite-math-only option:

-ffinite-math-only
Allow optimizations for floating-point arithmetic that assume that arguments
and results are not NaNs or +-Infs. 
This option should never be turned on by any -O option since it can result in
incorrect output for programs which depend on an exact implementation of IEEE
or ISO rules/specifications. 
The default is -fno-finite-math-only.

-- 
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.


             reply	other threads:[~2012-06-21 13:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21 13:25 pdemarco at maplesoft dot com [this message]
2012-06-21 14:27 ` [Bug math/14273] " jsm28 at gcc dot gnu.org
2012-06-21 14:37 ` carlos_odonell at mentor dot com
2012-06-21 15:06 ` bugdal at aerifal dot cx
2012-06-21 16:31 ` carlos_odonell at mentor dot com
2012-06-21 16:37 ` carlos_odonell at mentor dot com
2012-06-21 19:30 ` jsm28 at gcc dot gnu.org
2012-06-22  3:27 ` bugdal at aerifal dot cx
2012-06-22 13:49 ` carlos_odonell at mentor dot com
2012-06-26 18:55 ` jsm28 at gcc dot gnu.org
2012-06-28  2:25 ` carlos_odonell at mentor dot com
2012-06-28 12:15 ` jsm28 at gcc dot gnu.org
2012-07-03 17:08 ` jsm28 at gcc dot gnu.org
2014-06-13 14:04 ` fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-14273-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).