Bug 43346 - exp2(x) won't return denormal numbers
Summary: exp2(x) won't return denormal numbers
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libc
Version: 7.1
Hardware: All
OS: Linux
low
low
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-06-03 15:08 UTC by Trevin Beattie
Modified: 2008-05-01 15:38 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2001-06-05 07:57:24 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 15:08:18 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i586)

Description of problem:
exp2 (-1070) returns 0; should be representable as a denormal.


How reproducible:
Always

Steps to Reproduce:
Compile and run the following code:

#include <stdio.h>
#define __USE_ISOC99 1
#include <math.h>

main ()
{
  double a, b;

  a = exp2 (-1070);
  b = (double) exp2l (-1070);
  if (a == b) {
    printf ("exp2 (-1070) == (double) exp2l (-1070)\n");
    return 0;
  } else {
    printf ("exp2 (-1070) returned %g; should be %g\n", a, b);
    return 1;
  }
}


Actual Results:  exp2 (-1070) returned 0; should be 7.90505e-323


Expected Results:  exp2 (-1070) == (double) exp2l (-1070)


Additional info:

This problem doesn't exist in __ieee754_exp2, but the wrapper function exp2
is changing its return value.


Suggested fix:
diff -c glibc-2.2.3/sysdeps/generic/w_exp2.c.orig
glibc-2.2.3/sysdeps/generic/w_exp2.c
*** glibc-2.2.3/sysdeps/generic/w_exp2.c.orig   Fri Feb 16 17:42:18 2001
--- glibc-2.2.3/sysdeps/generic/w_exp2.c        Sun Jun  3 08:09:10 2001
***************
*** 7,13 ****
  #include "math_private.h"
  
  static const double o_threshold= (double) DBL_MAX_EXP;
! static const double u_threshold= (double) DBL_MIN_EXP;
  
  double
  __exp2 (double x)             /* wrapper exp2 */
--- 7,13 ----
  #include "math_private.h"
  
  static const double o_threshold= (double) DBL_MAX_EXP;
! static const double u_threshold= (double) (DBL_MIN_EXP - DBL_MANT_DIG -
1) - 1.0;
  
  double
  __exp2 (double x)             /* wrapper exp2 */

Comment 2 Jakub Jelinek 2001-06-07 13:17:56 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.