<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for OS/2 (vers 1 September 2005), see www.w3.org">
<style type="text/css">
del { font-weight:bold;background-color:#ffa0a0 }
ins { font-weight:bold;background-color:#a0ffa0 }
blockquote {
display: block;
font-family: "Times New Roman";
background-color:lightgray;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-right: 40px
}
</style>
<title>N25??: Exact subnormal results</title>
</head>
<body>
<p><br>
<!-- Who are the authors... -->
<b>Submitter:</b>CFP group<br>
<!-- What is the date of submission. yyyy-mm-dd -->
<b>Submission Date:</b> 2020-??-??<br>
<b>Document:</b> WG14 N25??<br>
<b>Title:</b> N25??: Exact subnormal results<br>
<b>Reference Documents:</b>N2478, N2506</p>
<p>Summary</p>
<p>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.</p>
<p>WG14 N2478 in <b>7.12.1 Treatment of error conditions</b> has
two "requirements" related to this issue.</p>
<p>#4 has:</p>
<blockquote>
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.
</blockquote>
<p>#6 has:</p>
<blockquote>
The result underflows if the magnitude of the mathematical
result is nonzero and less than the minimum normal number in
the type.243)
<p>243) The term underflow here is intended to encompass both
"gradual underflow" as in IEC 60559 and also "flush-to-zero"
underflow.</p>
</blockquote>
<p>So, if an exact subnormal result is produced, is it an
underflow range error?</p>
<p>Since it is exact, it is representable, so does not meet the
condition in paragraph 4.</p>
<p>Since it is subnormal, it meets the condition of paragraph
6.</p>
<p>So what is it?</p>
<p>With alternate exception handling (currently not part of C2X),
IEC 60559 requires that exact subnormal results be an underflow
exception.</p>
<p>Assuming WG14 wants exact subnormal results to be an
underflow, here are proposed wording changes to the C2X
standard.</p>
<p>Note: Since whether errno acquires the value ERANGE on
underflow is implementation-defined, these changes do NOT cause
any existing implementation to change.</p>
<p>C2x changes:</p>
<ul>
<li>7.12.1 Treatment of error conditions
<p>Change 7.12.1#4 first sentance to.</p>
<blockquote>
Likewise, a range error occurs <del>if and only if the
mathematical result of the function cannot be represented
in an object of the specified type, due to extreme
magnitude</del> <ins>if the finite non-zero 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</ins>.
</blockquote>
<p>Change footnote 243 of 7.12.1#6. to</p>
<blockquote>
243) The term underflow here is intended to encompass both
"gradual underflow" as in IEC 60559 and also
"flush-to-zero" underflow. <ins>A range error occurs if the
function result is subnormal, even if the mathematical
result is represented exactly in the type.</ins>
</blockquote>
</li>
<li>The fmod functions
<p>Add to 7.12.10.1#2</p>
<blockquote>
<ins>A range error occurs if x is finite, both x and y are
nonzero, and either is too close to zero.</ins>
</blockquote>
</li>
<li>The remainder functions
<p>Add to 7.12.10.2#2</p>
<blockquote>
<ins>A range error occurs if x is finite, both x and y are
nonzero, and either is too close to zero.</ins>
</blockquote>
</li>
<li>The fdim functions
<p>Change 7.12.12.1#2</p>
<blockquote>
A range error may occur.
</blockquote>
<p>to:</p>
<blockquote>
A range error <del>may occur</del><ins>occurs if positive
finite x-y is either too large or too close to zero.</ins>
</blockquote>
</li>
<li style="list-style: none">
<p>Change F.10.9.1 The fdim functions</p>
<blockquote>
No aditional requirements.
</blockquote>
<p>to:</p>
<blockquote>
<del>No aditional requirements.</del> <ins>A subnormal
result (if supported), is exact and is independent of the
current rounding direction mode.</ins>
</blockquote>
</li>
</ul>
<p>Question: Should statements like</p>
<blockquote>
The returned value is exact and is independent of the current
rounding direction mode.
</blockquote>be moved from Annex F to 7.12 math.h?
</body>
</html>