Bug 43346 - exp2(x) won't return denormal numbers
exp2(x) won't return denormal numbers
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: libc (Show other bugs)
7.1
All Linux
low Severity low
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-06-03 11:08 EDT by Trevin Beattie
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-06-05 03:57:24 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Trevin Beattie 2001-06-03 11:08:18 EDT
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 09:17:56 EDT
Included in glibc-2.2.3-11.

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