Article View: muc.lists.freebsd.bugs
Article #92[Bug 299389] [libm] nextafter[fl] and nexttoward[fl] return incorrect results for MAX value depending on rounding mode
From: bugzilla-noreply
Date: Wed, 14 Oct 2026 17:00
Date: Wed, 14 Oct 2026 17:00
55 lines
3523 bytes
3523 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299389
Bug ID: 299389
Summary: [libm] nextafter[fl] and nexttoward[fl] return
incorrect results for MAX value depending on rounding
mode
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs@FreeBSD.org
Reporter: kargl@FreeBSD.org
While scanning the openlibm bugs, I found
https://github.com/JuliaMath/openlibm/issues/361
which contains code that shows FreeBSD libm (may?) produces
wrong results. For example, the openlibm bug states
that with FE_UPWARD the following code should return
-inf, but it does not! [Note, I have not looked at
any of the drafts I have of the C standard to determine
what the correct behavior is.]
% cat next.c
int
main(void)
{
int rnd;
double x, y;
x = -DBL_MAX;
rnd = fegetround();
fesetround(FE_UPWARD);
y = nextafter(-DBL_MAX, -INFINITY);
fesetround(rnd);
printf("nextafter(%la, -inf) = %le %la\n", x, y, y);
return 0;
}
% cc -o z next.c -lm && ./z
nextafter(-0x1.fffffffffffffp+1023, -inf) = -1.797693e+308
-0x1.fffffffffffffp+1023
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<bug-299389-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 299389] [libm] nextafter[fl] and nexttoward[fl] return incorrect results for MAX value depending on rounding mode Date: Wed, 14 Oct 2026 17:00:11 +0000 Organization: Newsgate at muc.de e.V. Sender: owner-freebsd-bugs@FreeBSD.org Approved: news-admin@muc.de Distribution: world Message-ID: <bug-299389-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="58806"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791997211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S4OQpfZ94kzyQ46w9RDuv4Nbs2AQK7f9Xri9ecoq5Wo=; b=t0635LzF+svaRsGdrZwTzb18ZiTwVLnnhhLAJWoU7UOxdsFvPvc/ijx4+zBnt4tyF5jiD2 szlQwYRJLF2MMOV7CKWOxkL5QSkDaBGLl4PY5hF5WRlpNNUgX9QJJDJM9VxMmavIJXXJcJ 9ZUjHGcyEk9HZOTZojWnknr8eNdL/XqS+d4qOItrTiuNbul8tIK2ROGOxnO3Bfl4wyfWRN RbT+gi5igGlsGx5RPCjYo9xy7zhd9DN9H7IHZonTKrGxEuCqrse1KHaSZf1s25svq4GYNs jibAeGq9ATnmeHTRYnGjIl+SMpyCVMYYqgFnGrWdAOWR1cvjwOpgFCRyuNZ8aA== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes