>From the numpy test suite, I think I might have found a bug in
nextafterl(3). The "result_ld" variable below comes back as nan on
i386. But doing the same calculations with floats returns the expected
values.
A test on Linux also shows the expected results for both the float and
long double cases.
---[ on linux/x86_64 ]-------------------
# gcc -lm test2.c && ./a.out
1.000000e+00
-5.421011e-20
OK
1.000000
-0.000000
OK
---[ on openbsd/i386 ]-------------------
# gcc -lm test2.c && ./a.out
1.000000e+00
nan <-------------- this looks wrong
1.000000
-0.000000
OK
---[ test2.c ]-------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
long double one_ld;
long double zero_ld;
long double after_ld;
long double result_ld;
one_ld = 1.0L;
zero_ld = 0.0L;
after_ld = nextafterl(one_ld, zero_ld);
printf("%Le\n", after_ld);
result_ld = after_ld - one_ld;
// result_ld should not be nan
printf("%Le\n", result_ld);
if (result_ld < 0)
printf("OK\n");
float one_f;
float zero_f;
float after_f;
float result_f;
one_f = 1.0;
zero_f = 0.0;
after_f = nextafterf(one_f, zero_f);
printf("%f\n", after_f);
result_f = after_f - one_f;
printf("%f\n", result_f);
if (result_f < 0)
printf("OK\n");
}