This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/887] Math library function "logb" and "nextafter" inconsistent
- From: "rsa at us dot ibm.com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: Thu, 23 Feb 2012 21:28:45 +0000
- Subject: [Bug math/887] Math library function "logb" and "nextafter" inconsistent
- Auto-submitted: auto-generated
- References: <bug-887-131@http.sourceware.org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=887
--- Comment #12 from Ryan S. Arnold <rsa at us dot ibm.com> 2012-02-23 21:28:45 UTC ---
Here's a testcase for nextafter:
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#include <float.h>
#define NUM_INPUTS 3
#define NUM_TOWARDS 2
int main() {
int i = 0;
int j = 0;
typedef union {
long long ll;
double d;
} input;
input ret;
input inputs[NUM_INPUTS] =
{
[0].ll = 0x3000000000000001LL,
[1].ll = 0x0000000000000001LL,
[2].ll = 0x0000000000000000LL,
};
double toward[NUM_TOWARDS] =
{
-__DBL_MAX__,
__DBL_MAX__
};
for (j=0;j<NUM_TOWARDS;j++)
{
for (i=0;i<NUM_INPUTS;i++)
{
printf ("Input: %.*e\n [0x%0.16llx]\n",
__DBL_MANT_DIG__,
inputs[i].d,
inputs[i].ll);
printf ("Toward: %.*e\n",__DBL_MANT_DIG__,toward[j]);
fesetround (FE_TONEAREST);
ret.d = nextafter(inputs[i].d,toward[j]);
printf ("%.*e\n [0x%0.16llx]\n",
__DBL_MANT_DIG__,
ret.d,ret.ll);
fesetround (FE_DOWNWARD);
ret.d = nextafter(inputs[i].d,toward[j]);
printf ("%.*e\n [0x%0.16llx]\n\n",
__DBL_MANT_DIG__,
ret.d,
ret.ll);
}
}
return 0;
}
Using gcc version 4.1.2 20070115 (SUSE Linux)
The result is:
Input: 1.72723371101888930860019734894496687483038405619004088e-77
[0x3000000000000001]
Toward: -1.79769313486231570814527423731704356798070567525844997e+308
1.72723371101888892507727037256007991422320007288725628e-77
[0x3000000000000000]
1.72723371101888892507727037256007991422320007288725628e-77
[0x3000000000000000]
Input: 4.94065645841246544176568792868221372365059802614324764e-324
[0x0000000000000001]
Toward: -1.79769313486231570814527423731704356798070567525844997e+308
0.00000000000000000000000000000000000000000000000000000e+00
[0x0000000000000000]
0.00000000000000000000000000000000000000000000000000000e+00
[0x0000000000000000]
Input: 0.00000000000000000000000000000000000000000000000000000e+00
[0x0000000000000000]
Toward: -1.79769313486231570814527423731704356798070567525844997e+308
-4.94065645841246544176568792868221372365059802614324764e-324
[0x8000000000000001]
-4.94065645841246544176568792868221372365059802614324764e-324
[0x8000000000000001]
Input: 1.72723371101888930860019734894496687483038405619004088e-77
[0x3000000000000001]
Toward: 1.79769313486231570814527423731704356798070567525844997e+308
1.72723371101888969212312432532985383543756803949282549e-77
[0x3000000000000002]
1.72723371101888969212312432532985383543756803949282549e-77
[0x3000000000000002]
Input: 4.94065645841246544176568792868221372365059802614324764e-324
[0x0000000000000001]
Toward: 1.79769313486231570814527423731704356798070567525844997e+308
9.88131291682493088353137585736442744730119605228649529e-324
[0x0000000000000002]
9.88131291682493088353137585736442744730119605228649529e-324
[0x0000000000000002]
Input: 0.00000000000000000000000000000000000000000000000000000e+00
[0x0000000000000000]
Toward: 1.79769313486231570814527423731704356798070567525844997e+308
4.94065645841246544176568792868221372365059802614324764e-324
[0x0000000000000001]
4.94065645841246544176568792868221372365059802614324764e-324
[0x0000000000000001]
So I'm not seeing this reproduce for nextafter.
--
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.