[Cfp-interest 2066] Re: Underflow

Jim Thomas jaswthomas at sbcglobal.net
Tue Jul 20 12:41:18 PDT 2021



> On Jul 20, 2021, at 9:52 AM, David Hough CFP <pcfp at oakapple.net> wrote:
> 
>> My naive expectation would be that if nothing else, underflow is set =
> consistently with the result; so if you raise underflow, the result must =
> have magnitude <=3D min_normal.
> 
> I might be losing the thread here, but It's about ERANGE, right?

C underflow is a defined condition — it’s this definition we’re struggling with. Some cases of the condition are required or implementation-defined range errors. In those required or implementation-defined cases an implementation MAY report the underflow range error, either by setting errno to ERANGE or by raising the “underflow” floating-point exception. Given this weak  specification, the C underflow definition needs to be inclusive of the cases where the “underflow” floating-point exception might be raised.
> 
> Is it possible to specify in general, underflow ERANGE SHALL BE indicated when
> the computed result is subnormal or inexact zero.
> 
> But for implementations claiming IEEE conformance, underflow ERANGE MAY also
> be indicated when an IEEE underflow exception is signaled (and thus might
> correspond to exact subnormal or inexact minimum normal or alternate 
> exception handling).    Note that IEEE underflow can be signaled with no
> visible effect, as for exact subnormal results.
> 

Adapting this approach to the underflow definition (but without making IEC 60559 conformance a special case), we might have:

	The result underflows if it is subnormal, inexact zero, or inexact with the magnitude of the minimum normalized number in the type 249).

This doesn’t match the style of the C overflow definition in the same proposal, N2746. And I don’t see how to rewrite the overflow definition in this style. It also brings the term “subnormal” (an extension feature) into the specification. And it might not be reasonable to expect the implementation to determine exactness.


Here’s another rewrite of the definition in N2746 that excludes the exact minimum case from being a C underflow (and keeps the style of the overflow definition):

The result underflows if a nonzero result with ordinary accuracy would have magnitude (absolute value) too small for representation as a normalized number in an object of the specified type. Also, the result may underflow if it (with ordinary accuracy) can be represented as a minimum-magnitude number in an object of the specified type and it is inexact 249).



- Jim Thomas


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20210720/30c51580/attachment.htm>


More information about the Cfp-interest mailing list