[Cfp-interest 2040] Re: Subnormals

Jim Thomas jaswthomas at sbcglobal.net
Sun Jun 27 16:15:29 PDT 2021


Some general comments …

It’s common for CPUs to have behavior-changing controls that can be changed at execution time. Implementations should generally be able to define characteristics of their floating-point arithmetic based on a default configuration of such controls. For example, an implementation on a 754 CPU with trap enablement modes should be able to conform to Annex F, even though a user might enable traps thereby causing non-conforming behavior. Also, C doesn’t provide a way for a user to change the behaviors related to subnormals and underflow. A program that does so is going outside the C standard. I think we should avoid “changeable at runtime”.

IEC 60559 is a well-defined floating-point standard. We don’t have a viable more general standard (LIA?) that covers arithmetics that don’t conform to IEC 60559. There are limitless possibilities. I don’t think C should try to characterize non-standard behaviors just because they appear in an implementation. It might be different if a behavior is widely adopted in a uniform way. Are we trying codify some such existing practice?

What is the purpose of the macro? Presumably, it is intended to tell a program something useful about the arithmetic. Considering the scope of possibilities for how subnormals might be treated, how can this macro provide information that code might be based on? Are there examples of real code that uses it? If so, how do they use it?

“Flush to zero” is not defined and is used only once in C, in a footnote. A related problem is that the operations that flush results to zero would need to be identified (or characterized). For example, would negate (-), fabs, and copysign be expected to flush to zero? How about conversion to same or wider format?

Some specific comments (in brackets) …

So, if subnormal operands are treated as zero, then subnormal numbers could be considered as non-canonical encodings of zero.

[Comment: The words here confuse the distinction between the representation and the value. Consider changing the sentence above to: … if subnormal representations are treated as zero values, then they can be regarded as non-canonical zero representations.]

That would mean (independent of flushing subnormal results):

...	

        • nextdown(minimum normal) is true zero. [Comment: Why “true” zero? Does true zero mean canonical zero? Functions for such implementations are not required to produce canonical results.]

	• signbit(-subnormal) is same as signbit(1.e0 * -subnormal); [Comment: Why?] which could be positive (zero). [Comment: I don’t think we’ve said anything about how implementations that treat subnormal representations as zero values must treat the sign bit of such representations.]

However, if subnormal operands are NOT treated as zero, that would mean (independent of flushing subnormal results):

...
	• iscanonical(subnormal) is true (non-zero). [Comment: Depends on whether the representation of the subnormal is canonical.]

- Jim Thomas

> On Jun 24, 2021, at 6:11 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> 
> Attached is a zip file of my proposal on subnormals.
> Comments welcome.
> 
> 
> ---
> Fred J. Tydeman        Tydeman Consulting
> tydeman at tybor.com      Testing, numerics, programming
> +1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
> Sample C99+FPCE tests: http://www.tybor.com
> Savers sleep well, investors eat well, spenders work forever.
> 
> <SUBNORM.ZIP>_______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest




More information about the Cfp-interest mailing list