[Cfp-interest 2096] Re: number classification macros, fpclassify and normal numbers

Jim Thomas jaswthomas at sbcglobal.net
Sun Aug 15 09:29:16 PDT 2021


Following up on this thread, we might propose …

After 5.2.4.2.2 #4, and before the new paragraph proposed in [Cfp 2094], add:

A number whose magnitude (absolute value) is at least the minimum positive normalized floating-point number in the type and at most the maximum finite number in the type is a normal number.*) A nonzero number whose magnitude is less than the minimum positive normalized floating-point number in the type is a subnormal number. 

*) All normalized floating-point numbers are normal numbers. In IEC 60559 basic binary formats, the two are equivalent.

In 7.12 #12, change:

represent the mutually exclusive kinds of floating-point values.

In 7.12.3.6 #2, change:

The isnormal macro determines whether its argument value is normal (neither zero, subnormal, infinite, nor NaN).

- Jim Thomas

> On Aug 3, 2021, at 7:34 PM, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> It seems that the classification macros introduced in 7.12p12 of C2x
> N2596 (FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL and FP_ZERO) are
> not explicitly defined. This may be obvious with the fpclassify
> description in 7.12.3.1p2, but it seems that "normal" has not been
> defined yet ("normalized" has been defined, but not "normal").
> 
> 7.12.3.6p2 says "The isnormal macro determines whether its argument
> value is normal (neither zero, subnormal, infinite, nor NaN)." but
> this does not constitute a definition (it is not in italic), and
> "neither zero, subnormal, infinite, nor NaN" excludes the possible
> implementation-defined categories allowed for fpclassify.
> 
> Note that for a strict floating-point format, "normal" should be
> the same as "normalized". But with values that are neither zero,
> subnormal, infinite, NaN, nor normalized, which may occur with the
> double-double format (conventional "long double" type on PowerPC),
> the meaning is ambiguous. Should the standard add some requirement,
> or should it make this implementation-defined?
> 
> GCC assumes the following definition in gcc/builtins.c:
> 
>        /* isnormal(x) -> isgreaterequal(fabs(x),DBL_MIN) &
>           islessequal(fabs(x),DBL_MAX).  */
> 
> (for double; similar for the other types), where DBL_MIN is the
> minimum *normalized* positive floating-point number and DBL_MAX
> is the maximum representable finite number (see N2092[*]). Note:
> N2596 says "maximum representable finite floating-point number",
> but "floating-point" should be dropped to avoid ambiguity.
> 
> [*] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2092.htm
> 
> Thus for double-double, the only possibilities are zero, subnormal,
> normal, infinite and NaN. And a value may be classified as a normal
> number while not being a normalized floating-point number. Example:
> 1 + 2^(-200). It is not a normalized floating-point number because
> it does not fit in LDBL_MANT_DIG = 106 bits (as defined by GCC on
> PowerPC).
> 
> -- 
> Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20210815/37a59021/attachment-0001.htm>


More information about the Cfp-interest mailing list