Bug 44663 - nextafterl() produces incorrect result when 2nd argument is infinite
nextafterl() produces incorrect result when 2nd argument is infinite
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2001-06-14 23:15 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:
Last Closed: 2001-06-15 08:07:32 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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 00:00:00 EDT

  None (edit)
Description Trevin Beattie 2001-06-14 23:15:13 EDT
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.

How reproducible:

Steps to Reproduce:
Compile and run the following program:

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

main ()
  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

Additional info:

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
be hiding.

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
Comment 1 Jakub Jelinek 2001-06-15 01:19:34 EDT
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.
Comment 3 Jakub Jelinek 2001-08-08 09:23:23 EDT
This is fixed since glibc-2.2.3-12.

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