[Cfp-interest 1797] Re: Exact subnormal results

Jim Thomas jaswthomas at sbcglobal.net
Tue Oct 20 15:02:06 PDT 2020



> On Sep 23, 2020, at 11:15 AM, Fred J. Tydeman <tydeman at tybor.com> wrote:
> 
> I will leave the issue of gradual overflow to another proposal.
> Here is an updated exact subnormal results proposal.
> 
> 
> ---
> Fred J. Tydeman        Tydeman Consulting
> tydeman at tybor.com <mailto: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 <http://www.tybor.com/>
> Savers sleep well, investors eat well, spenders work forever.
> 
> 
> Submitter:CFP group
> Submission Date: 2020-??-??
> Document: WG14 N25??
> Title: N25??: Exact subnormal results
> Reference Documents:N2478, N2506
> 
> Summary
> 
> This is a follow on to N2506 that was accepted (except for three math functions). Those three functions [fmod(), remainder(), and remquo()] can produce exact subnormal results and there was a question on should they underflow.
> 
> WG14 N2478 in 7.12.1 Treatment of error conditions has two "requirements" related to this issue.
> 
> #4 has:
> 
> Likewise, a range error occurs if and only if the mathematical result of the function cannot be represented in an object of the specified type, due to extreme magnitude.
> #6 has:
> 
> The result underflows if the magnitude of the mathematical result is nonzero and less than the minimum normal number in the type.243)
> 243) The term underflow here is intended to encompass both "gradual underflow" as in IEC 60559 and also "flush-to-zero" underflow.
> 
> So, if an exact subnormal result is produced, is it an underflow range error?
> 
> Since it is exact, it is representable, so does not meet the condition in paragraph 4.
> 
> Since it is subnormal, it meets the condition of paragraph 6.
> 
> So what is it?
> 
> With alternate exception handling (currently not part of C2X), IEC 60559 requires that exact subnormal results be an underflow exception.
> 
> Assuming WG14 wants exact subnormal results to be an underflow, here are proposed wording changes to the C2X standard.
> 
> Note: Since what happens on underflow is implementation defined,
> 
Better to say “Since whether errno acquires the value ERANGE on underflow is implementation-defined,
> these changes do NOT cause any existing implementation to change.
> 
> C2x changes:
> 
> 7.12.1 Treatment of error conditions
> Add to 7.12.1#4 after the first sentance.
> 
> Also, a range error occurs if the finite mathematical result is beyond the range where all values can be represented in an object of the specified type, to the full precision of the type.
The second sentence implies the first, so there’s no need for two sentences.

> Change footnote 243 of 7.12.1#6. to
> 
> 243) The term underflow here is intended to encompass both "gradual underflow" as in IEC 60559 and also "flush-to-zero" underflow. A range error occurs if the function result is subnormal, even if the mathematical result is represented exactly in the type.
> The fmod functions
> Add to 7.12.10.1#2
> 
> A range error occurs if x is finite, both x and y are nonzero, and either is too close to zero.
> The remainder functions
> Add to 7.12.10.2#2
> 
> A range error occurs if x is finite, both x and y are nonzero, and either is too close to zero.
> The fdim functions
> Change 7.12.12.1#2
> 
> A range error may occur.
> to:
> 
> A range error may occuroccurs if positive finite x-y is either too large or too close to zero.
> Change F.10.9.1 The fdim functions
> 
> No aditional requirements.
> to:
> 
> No aditional requirements. When subnormal results are supported, the returned value is exact and is independent of the current rounding direction mode.
Why is this change needed? This is in Annex F, so subnormal results must be supported. This also applies to existing text in F.10.7.2 (remainder) and F.10.7.3 (remquo). 
The new sentence is at best vague for fdim: it appears to say all returned values are exact. Annex F wasn’t written to  identify all exact cases. 

- Jim Thomas
 
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net <mailto:Cfp-interest at oakapple.net>
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest <http://mailman.oakapple.net/mailman/listinfo/cfp-interest>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20201020/8101d772/attachment-0001.htm>


More information about the Cfp-interest mailing list