<!-- saved from url=(0022)http://internet.e-mail -->
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>I</title>
</head>

<body>

<blockquote>
  <p><b>Author:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  Fernando Cacciola<br>
  <b>Contact:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="mailto:fernando.cacciola@gmail.com">fernando.cacciola@gmail.com</a><br>
  <b>Organization:&nbsp;&nbsp;&nbsp; </b>SciSoft<br>
  <b>Date:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  2005-08-29<br>
  <b>Number:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  N1880=05-0140</p>
  <h1>A proposal to extend numeric_limits for consistent range query (Revision 1)</h1>
  <h1><b><i>Motivation and Scope</i></b></h1>
  <p><code>numeric_limits::min()</code> (18.2.1.2) is defined with a meaning which is 
  inconsistent across integer and floating-point types. Specifically, for 
  integer types, it is the minimum finite value whereas for floating point types 
  it is the minimum <i>positive</i> normalized value. The inconsistency here 
  lies in the interpretation of <i>minimum</i>: in the case of integer types, it 
  signifies <b>lowest</b>, while for floating point types, it signifies <b>
  smallest non-zero</b>.</p>
  <p>Though the smallest non-zero value of a floating point type is important 
  for floating point computations, the lowest arithmetic value is important 
  because it indicates the lower bound of the numeric range. In fact, lowest is 
  a concept applicable to any arithmetic type and so is more general.</p>
  <p>Using <code>numeric_limits&lt;T&gt;::min()</code>, the lowest value is given by: </p>
  <ul>
    <li><code> &nbsp;numeric_limits&lt;T&gt;::min()</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if <code>T</code> is an integer type</li>
    <li><code>-numeric_limits&lt;T&gt;::max()</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if <code>T</code> is a 
    floating-point type</li>
  </ul>
  <p>In practice, the inconsistency causes two problems: first, usage of 
  <code>numeric_limits::min()</code> in generic code requires the code to distinguish if the 
  type is integer or floating point, and to do so using template 
  metaprogramming if performance is important. Second, and more important, it 
  confuses users. A web search for &quot;numeric_limits::min&quot; shows that ever since 
  the Standard was released and up to the present day lots of users get this the 
  wrong way expecting min() to mean lowest.</p>
  <p>This proposal suggests to fix this by adding the additional function 
  <code>numeric_limits::lowest()</code>.</p>
  <h1><i><b>Impact On the Standard</b></i></h1>
  <p>The proposal is not to change the meaning of min() (which could break 
  existing code) but to add a new lowest() function that provides the expected meaning 
  consistently.</p>
  <h1><b><i>Proposed Text for the Standard</i></b></h1>
  <p><i>A.</i> Add to 18.2.1.1 [lib.numeric.limits]:&nbsp; <code>static T lowest() throw;</code> below 
  <code>max();</code></p>
  <p><i>B</i>. Insert in 18.2.1.2 [lib.numeric.limits.members], below <code>max()</code>:</p>
  <pre>static T lowest() throw();</pre>
  <p>&nbsp; 1.For integer types, returns min(); for floating point types, return 
  -max();</p>
  <h1><b><i>Acknowledgements</i></b></h1>
  <p>All the people in the boost community, particularly those involved in the 
  development of the Boost.NumericConversion library.</p>
  <p>Thorsten Ottosen for his help preparing this proposal.</p>
  <h1><b><i>References</i></b></h1>
  <p>Boost.Numeric Conversion Library, 
  <a href="http://www.boost.org/libs/numeric/conversion/doc/index.html">http://www.boost.org/libs/numeric/conversion/doc/index.html</a>, Fernando Cacciola</p>
</blockquote>

</body>

</html>