Bug 43355

Summary: coshl(x) fails when x >= 711
Product: [Retired] Red Hat Linux Reporter: Trevin Beattie <trevin>
Component: libcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-06-05 08:03:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Trevin Beattie 2001-06-03 19:16:20 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i586)

Description of problem:
The result of coshl(x) (defined as (e^x - e^-x)/2) should be representable
for all x where |x| <= 11357, but it overflows to infinity when |X| >= 711.


How reproducible:
Always

Steps to Reproduce:
Compile and run the following program:

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

main ()
{
  long double a, b;
  const long double test_cases[] = { 711.0L, 11356.0L };
  int i, r = 0;

  for (i = 0; i < sizeof (test_cases) / sizeof (test_cases[0]); i++) {
    a = coshl (test_cases[i]);
    b = (expl (test_cases[i]) - expl (-test_cases[i])) / 2.0L;
    if (a == b) {
      printf ("cosh(%Lg) = %Lg\n", a);
    } else {
      printf ("coshl(%Lg) returned %Lg; expected %Lg\n",
	      test_cases[i], a, b);
      r = 1;
    }
  }
  return r;
}


Actual Results:  coshl(711) returned inf; expected 3.03631e+308
coshl(11356) returned inf; expected 3.52457e+4931


Expected Results:  cosh(711) = 3.03631e+308
cosh(11356) = 3.52457e+4931


Additional info:

The source of this bug can be found in
glibc-2.2.3/sysdeps/generic/w_coshl.c.  When it checks for a range error,
it is using the domain limit of the double function
(710.475860073943863426) rather than the long double version
(11357.2165534747038948012940999836L).

Comment 1 Jakub Jelinek 2001-06-03 19:24:17 UTC
Then there should be special sysdeps/ieee754/ldbl-{96,128}/w_coshl.c,
I'll compute the constants tomorrow.

Comment 3 Jakub Jelinek 2001-06-07 13:19:51 UTC
Included in glibc-2.2.3-11.