<!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>Nxxxx: Range errors and math functions</title>
</head>

<body>
  <p><br>
  <!-- Who are the authors... -->
   <b>Submitter:</b>Fred Tydeman<br>
  <!-- What is the date of submission. yyyy-mm-dd -->
   <b>Submission Date:</b> 2020-02-??<br>
  <b>Document:</b> WG14 Nxxxx<br>
  <b>Reference Documents:</b></p>

  <p>Summary</p>

  <p>The standard has a few incorrect, missing, or ambiguous
  statements about range errors in some of the math functions.</p>

  <p>Does "too large" mean close to +infinity or +/-infinity?</p>

  <p>Does "too small" mean close to -infinity or +/-zero?</p>

  <p>It appears that "magnitude" has no formal definition.</p>

  <p>Some implementations incorrectly treat f(infinity) as a range
  error based upon the text: A range error occurs if [the magnitude
  of] x is too large. While this is covered by 7.12.1#5 about
  overflows, the CFP group believes it is better to be explicit in
  each math function where it matters.</p>

  <p>Possible Technical Corrigendum:</p>

  <ul>
    <li>Sizes of integer types &lt;limits.h&gt;

      <p>Change 5.2.4.2.1#1 to give magnitude a definition</p>

      <blockquote>
        ... magnitude (absolute value) ...
      </blockquote>to:

      <blockquote>
        ... <i>magnitude</i> (absolute value) ...
      </blockquote>
    </li>

    <li>Treatment of error conditions

      <p>Change 7.12.1#5</p>

      <blockquote>
        ... overflows if the magnitude ...
      </blockquote>to:

      <blockquote>
        ... overflows if the magnitude <ins>(absolute value)</ins>
        ...
      </blockquote>
    </li>

    <li>Treatment of error conditions

      <p>Change 7.12.1#6</p>

      <blockquote>
        ... underflows if the magnitude ...
      </blockquote>to:

      <blockquote>
        ... underflows if the magnitude <ins>(absolute value)</ins>
        ...
      </blockquote>
    </li>

    <li>The asin functions

      <p>Add to 7.12.4.2#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The atan functions

      <p>Add to 7.12.4.3#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The atan2 functions

      <p>Add to 7.12.4.4#2</p>

      <blockquote>
        <ins>A range error occurs if x is positive and nonzero y/x
        is too close to zero.</ins>
      </blockquote>
    </li>

    <li>The sin functions

      <p>Add to 7.12.4.6#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The tan functions

      <p>Add to 7.12.4.7#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The asinpi functions

      <p>Change 7.12.4.9#2</p>

      <blockquote>
        A range error occurs if the magnitude of nonzero x is too
        small.
      </blockquote>to:

      <blockquote>
        A range error occurs if <del>the magnitude of</del> nonzero
        x is too <del>small</del><ins>close to zero</ins>.
      </blockquote>
    </li>

    <li>The atanpi functions

      <p>Change 7.12.4.10#2</p>

      <blockquote>
        A range error occurs if the magnitude of nonzero x is too
        small.
      </blockquote>to:

      <blockquote>
        A range error occurs if <del>the magnitude of</del> nonzero
        x is too <del>small</del><ins>close to zero</ins>.
      </blockquote>
    </li>

    <li>The atan2pi functions

      <p>Change 7.12.4.11#2</p>

      <blockquote>
        A range error occurs if x is positive and the magnitude of
        nonzero y/x is too small.
      </blockquote>to:

      <blockquote>
        A range error occurs if x is positive and <del>the
        magnitude of</del> nonzero y/x is too <del>small</del>
        <ins>close to zero</ins>.
      </blockquote>
    </li>

    <li>The sinpi functions

      <p>Add to 7.12.4.13#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The tanpi functions

      <p>Add to 7.12.4.14#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The asinh functions

      <p>Add to 7.12.5.2#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The atanh functions

      <p>Add to 7.12.5.3#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The cosh functions

      <p>Change 7.12.5.4#2 from</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if the magnitude of <ins>finite</ins>
        x is too large.
      </blockquote>
    </li>

    <li>The sinh functions

      <p>Change 7.12.5.5#2 from</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if the magnitude of <ins>finite</ins>
        x is too large <ins>or if nonzero x is too close to
        zero</ins>.
      </blockquote>
    </li>

    <li>The tanh functions

      <p>Add to 7.12.5.6#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The exp functions

      <p>Change 7.12.6.1#2 from</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if the magnitude of <ins>finite</ins>
        x is too large.
      </blockquote>
    </li>

    <li>The exp10 functions

      <p>Change 7.12.6.2#2 from</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if the magnitude of <ins>finite</ins>
        x is too large.
      </blockquote>
    </li>

    <li>The exp10m1 functions

      <p>Change 7.12.6.3#2 from</p>

      <blockquote>
        A range error occurs if finite x is too large or if the
        magnitude of nonzero x is too small.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if <ins>positive</ins> finite x is too
        large or if <del>the magnitude of</del> nonzero x is too
        <del>small</del><ins>close to zero</ins>.
      </blockquote>
    </li>

    <li>The exp2 functions

      <p>Change 7.12.6.4#2 from</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if the magnitude of <ins>finite</ins>
        x is too large.
      </blockquote>
    </li>

    <li>The exp2m1 functions

      <p>Change 7.12.6.5#2 from</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large or
        if the magnitude of nonzero x is too small.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if <del>the magnitude of</del>
        <ins>positive finite</ins> x is too large or if <del>the
        magnitude of</del> nonzero x is too
        <del>small</del><ins>close to zero</ins>.
      </blockquote>
    </li>

    <li>The expm1 functions

      <p>Change 7.12.6.6#2 from</p>

      <blockquote>
        A range error occurs if positive x is too large.252)
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error occurs if positive <ins>finite</ins> x is too
        large <ins>or if nonzero x is too close to zero</ins>.252)
      </blockquote>
    </li>

    <li>The ldexp functions

      <p>Change 7.12.6.9#2 from</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs for some
        finite x, depending on p</ins>.
      </blockquote>
    </li>

    <li>The log10p1 function

      <p>Change 7.12.6.13#2</p>

      <blockquote>
        A range error occurs if the magnitude of nonzero x is too
        small.
      </blockquote>to:

      <blockquote>
        A range error occurs if <del>the magnitude</del> nonzero x
        is too <del>small</del><ins>close to zero</ins>.
      </blockquote>
    </li>

    <li>The log1p and logp1 functions

      <p>Add to 7.12.6.14#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The log2p1 functions

      <p>Add to 7.12.6.16#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The scalbn and scalbln functions

      <p>Change 7.12.6.19#2 from</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del> <ins>occurs for some
        finite x, depending on n</ins>.
      </blockquote>
    </li>

    <li>The compoundn functions

      <p>Change 7.12.7.2#2 from</p>

      <blockquote>
        A range error may occur if n is too large, depending on x.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs</ins> if
        <ins>positive finite x</ins> <del>n</del> is too large
        <ins>or if negative x is too near -1</ins>, depending on
        <ins>n</ins><del>x</del>.
      </blockquote>
    </li>

    <li>The hypot functions

      <p>Change 7.12.7.4#2 from</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs for some
        finite arguments</ins>.
      </blockquote>
    </li>

    <li>The pow functions

      <p>Change 7.12.7.5#2 from</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>ocurs if the
        magnitude of nonzero finite x is too large or too near
        zero, depending on y</ins>.
      </blockquote>
    </li>

    <li>The pown functions

      <p>Change 7.12.7.6#2 from</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs if the
        magnitude of nonzero finite x is too large or too near
        zero, depending on n</ins>.
      </blockquote>
    </li>

    <li>The powr functions

      <p>Change 7.12.7.7#2 from</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs if positive
        nonzero finite x is too large or too near zero, depending
        on y</ins>.
      </blockquote>
    </li>

    <li>The rootn functions

      <p>Change 7.12.7.8#2 from</p>

      <blockquote>
        A range error may occur if n is -1.
      </blockquote>

      <p>to</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs if the
        magnitude of nonzero finite x is too large or too near zero
        and</ins> <del>if</del> n is -1.
      </blockquote>
    </li>

    <li>The erf functions

      <p>Add to 7.12.8.1#2</p>

      <blockquote>
        <ins>A range error occurs if nonzero x is too close to
        zero.</ins>
      </blockquote>
    </li>

    <li>The erfc functions

      <p>Change 7.12.8.2#2</p>

      <blockquote>
        A range error occurs if positive x is too large.
      </blockquote>

      <p>to:</p>

      <blockquote>
        A range error occurs if positive <ins>finite</ins> x is too
        large.
      </blockquote>
    </li>

    <li>The lgamma functions

      <p>Change 7.12.8.3#2</p>

      <blockquote>
        A range error occurs if positive x is too large.
      </blockquote>

      <p>to:</p>

      <blockquote>
        A range error occurs if positive <ins>finite</ins> x is too
        large.
      </blockquote>
    </li>

    <li>The tgamma functions

      <p>Change 7.12.8.4#2</p>

      <blockquote>
        A range error occurs if the magnitude of x is too large and
        may occur if the magnitude of x is too small.
      </blockquote>

      <p>to:</p>

      <blockquote>
        A range error occurs <ins>for some negative finite x,
        and</ins> if <del>the magnitude of</del><ins>positive
        finite</ins> x is too large<ins>,</ins> and <del>may
        occur</del> if <del>the magnitude of</del> nonzero x is too
        <del>small</del><ins>close to zero</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 too large or too close to zero</ins>.
      </blockquote>
    </li>

    <li>The fma functions

      <p>Change 7.12.13.1#2</p>

      <blockquote>
        A range error may occur.
      </blockquote>

      <p>to:</p>

      <blockquote>
        A range error <del>may occur</del><ins>occurs for some
        finite arguments</ins>.
      </blockquote>
    </li>
  </ul>
</body>
</html>