This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Add nextup and nextdown math functions
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Rajalakshmi Srinivasaraghavan <raji at linux dot vnet dot ibm dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 2 Jun 2016 23:21:42 +0000
- Subject: Re: [PATCH] Add nextup and nextdown math functions
- Authentication-results: sourceware.org; auth=none
- References: <1463727477-1909-1-git-send-email-raji at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 20 dot 1605201155430 dot 22473 at digraph dot polyomino dot org dot uk> <201606011211 dot u51C9sVN019582 at mx0a-001b2d01 dot pphosted dot com>
On Wed, 1 Jun 2016, Rajalakshmi Srinivasaraghavan wrote:
> This patch adds nextup and nextdown functions from TS 18661-1 before
> enabling float128 support.
I think the description for the commit message should expand more on the
change and its rationale.
> +* TS 18661 adds nextup and nextdown functions alongside nextafter to
> + provide support for float128 equivalent to it. So nextup and nextdown
> + functions are added as preparatory patches before Float128 support. This
> + is currently enabled as a GNU extension.
But I don't think this is what a NEWS entry should look like. The
rationale for adding these particular functions in isolation is much less
relevant to the NEWS entry. Rather, it should say what functions are
added (six of them, not two), where they come from, what (briefly) they do
and that they are currently handled as a GNU extension (i.e. require
_GNU_SOURCE). Cf. the NEWS entry for the issignaling macro - the
motivation for adding that in isolation was for use in glibc tests (we
needed some functionality, there was a defined API for it to it made sense
to provide that API for use outside glibc), but that motivation is also
not relevant to people interested in what's new in a glibc version.
> +/* Copyright (C) 2016 Free Software Foundation, Inc.
New files should start with a description of the file *before* the
copyright notice.
> +/* nextdown(x) returns the least floating-point number in the
> + format of x less than x. */
Use the GNU standard formatting for comments on function definitions,
immediately above the function definition.
> +#include <math_private.h>
> +#include <float.h>
Don't include these where not needed.
> + INSERT_WORDS(x,(1&0x80000000),1); /* return +-minsubnormal */
This "(1&0x80000000)", and similar for other formats, makes no sense. In
this case, you simply mean "0". (The point being that nextup of -0 is the
least positive subnormal, but that is different from what you'd get by the
simple integer decrement of the representation that works for all other
non-NaN inputs where the sign is negative.)
> + /* return +-minsubnormal */
> + SET_LDOUBLE_WORDS64(x,-1&0x8000000000000000ULL,1);
"-1&0x8000000000000000ULL" in the ldbl-128 version actually seems wrong.
> diff --git a/sysdeps/ieee754/ldbl-96/s_nextupl.c b/sysdeps/ieee754/ldbl-96/s_nextupl.c
> + if (hx==0 || (esx == 0 && hx == 0x80000000)) {
> + esx += 1;
> + hx |= 0x80000000;
I'm not sure the special handling of (esx == 0 && hx == 0x80000000) is
correct for the m68k variant of ldbl-96 (LDBL_MIN_EXP == -16382); exponent
0 acts more like a normal exponent there so I think that bit of special
handling should be disabled in that case.
--
Joseph S. Myers
joseph@codesourcery.com