From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i586)
Description of problem:
nextafter(x,y) and friends are supposed to return the next representable
number after X in the direction of Y (unless Y is NaN). The double and
float versions work correctly, but on the i386 port, the long double
version will instead return Y if Y is +-infinity.
Steps to Reproduce:
Compile and run the following program:
#define __USE_ISOC99 1
long double delta;
delta = nextafterl (1.0L, INFINITY) - 1.0L;
printf ("1ulp = %Lg*2^exp\n", delta);
return (delta < 0.0L);
Actual Results: 1ulp = inf*2^exp
Expected Results: 1ulp = 1.0842e-19*2^exp
I've glanced at glibc-2.2.3/sysdeps/i386/fpu/s_nextafterl.c, but I can't
tell which block of code is being executed, much less where the bug could
In my own port of the function, I simply check the sign of X against (x <
y) (after checking that X and Y are ordered and unequal) and
increment/decrement X accordingly. There are a few special border cases
depending on the value of X, but the code works regardless of the value of
It is the IA-32 specific NaN check in i386/fpu/s_nextafterl.c
that is broken (IA-32 infinity has the topmost bit in middleword set).
I'll see if I get to fixing it before leaving for vacation today.
This is fixed since glibc-2.2.3-12.