This is the mail archive of the
`libc-alpha@sourceware.org`
mailing list for the glibc project.

# Re: Simplify HUGE_VAL definitions [committed]

*From*: Zack Weinberg <zackw at panix dot com>
*To*: Joseph Myers <joseph at codesourcery dot com>
*Cc*: GNU C Library <libc-alpha at sourceware dot org>
*Date*: Thu, 31 Aug 2017 12:48:53 -0400
*Subject*: Re: Simplify HUGE_VAL definitions [committed]
*Authentication-results*: sourceware.org; auth=none
*References*: <alpine.DEB.2.20.1708311551080.24662@digraph.polyomino.org.uk>

On Thu, Aug 31, 2017 at 11:51 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> There are various bits/huge_val*.h headers to define HUGE_VAL and
> related macros.
...
> This patch eliminates all those headers, defining the macros directly
> in math.h. For GCC 3.3 and later, the built-in functions are used as
> now. For other compilers, a large constant 1e10000 (with appropriate
> suffix) is used. This is like the fallback for GCC 2.96 and later,
> but without using hex floats (which have no apparent advantage here).
This seems a good change to me, but I would like to propose better
commentary in math.h, so that people unfamiliar with the requirements
of C90 + IEEE754 that make the fallback workable are pointed in the
right direction: instead of
> +/* Value returned on overflow. On all IEEE754 machines, this is
> + +Infinity. */
suggested wording is
/* Value returned on overflow; with IEEE 754 floating point, this is
+Infinity, otherwise the largest representable positive value.
GCC >=3.3 and compatible compilers provide an intrinsic function,
usable in constant expressions, that gives this value. Otherwise
use a numeric constant larger than the largest representable finite
value in any supported floating-point format; in the normal
rounding mode, ISO C requires this to be rounded to +Infinity, if
it exists, or else to the largest representable positive value.
(The intrinsic function is preferred because it will not produce
warnings about overflow and is not affected by rounding mode.) */
zw