Bug 43355 - coshl(x) fails when x >= 711
Summary: coshl(x) fails when x >= 711
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libc
Version: 7.1
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2001-06-03 19:16 UTC by Trevin Beattie
Modified: 2008-05-01 15:38 UTC (History)
0 users

Clone Of:
Last Closed: 2001-06-05 08:03:23 UTC

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2001:121 normal SHIPPED_LIVE GNU C Library bugfix update 2001-10-04 04:00:00 UTC

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:

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

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.

Note You need to log in before you can comment on or make changes to this bug.