public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/14273] New: cosh() returns incorrect results
@ 2012-06-21 13:25 pdemarco at maplesoft dot com
  2012-06-21 14:27 ` [Bug math/14273] " jsm28 at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: pdemarco at maplesoft dot com @ 2012-06-21 13:25 UTC (permalink / raw)
  To: glibc-bugs

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.


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

end of thread, other threads:[~2014-06-13 14:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-21 13:25 [Bug math/14273] New: cosh() returns incorrect results pdemarco at maplesoft dot com
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

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