mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-02 14:04:55 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Advancing a floating-point Value by a Specific Representation Distance (ULP) float_advance</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="prev" href="float_distance.html" title="Calculating the Representation Distance Between Two floating-point Values (ULP) float_distance">
|
||||
<link rel="next" href="ulp.html" title="Obtaining the Size of a Unit In the Last Place - ULP">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_distance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ulp.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.next_float.float_advance"></a><a class="link" href="float_advance.html" title="Advancing a floating-point Value by a Specific Representation Distance (ULP) float_advance">Advancing a floating-point
|
||||
Value by a Specific Representation Distance (ULP) float_advance</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Function <code class="computeroutput"><span class="identifier">float_advance</span></code> advances
|
||||
a floating-point number by a specified number of ULP.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_advance.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_advance.synopsis"></a></span><a class="link" href="float_advance.html#math_toolkit.next_float.float_advance.synopsis">Synopsis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">next</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">float_advance</span><span class="special">(</span><span class="identifier">FPT</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">distance</span><span class="special">);</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_advance.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_advance.description_float_advance"></a></span><a class="link" href="float_advance.html#math_toolkit.next_float.float_advance.description_float_advance">Description
|
||||
- float_advance</a>
|
||||
</h5>
|
||||
<p>
|
||||
Returns a floating-point number <span class="emphasis"><em>r</em></span> such that <code class="computeroutput"><span class="identifier">float_distance</span><span class="special">(</span><span class="identifier">val</span><span class="special">,</span> <span class="identifier">r</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">distance</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_distance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="ulp.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,106 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Calculating the Representation Distance Between Two floating-point Values (ULP) float_distance</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="prev" href="float_prior.html" title="Finding the Next Smaller Representable Value (float_prior)">
|
||||
<link rel="next" href="float_advance.html" title="Advancing a floating-point Value by a Specific Representation Distance (ULP) float_advance">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_prior.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_advance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.next_float.float_distance"></a><a class="link" href="float_distance.html" title="Calculating the Representation Distance Between Two floating-point Values (ULP) float_distance">Calculating the
|
||||
Representation Distance Between Two floating-point Values (ULP) float_distance</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Function float_distance finds the number of gaps/bits/ULP between any two
|
||||
floating-point values. If the significands of floating-point numbers are
|
||||
viewed as integers, then their difference is the number of ULP/gaps/bits
|
||||
different.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_distance.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_distance.synopsis"></a></span><a class="link" href="float_distance.html#math_toolkit.next_float.float_distance.synopsis">Synopsis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">next</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">float_distance</span><span class="special">(</span><span class="identifier">FPT</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">FPT</span> <span class="identifier">b</span><span class="special">);</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_distance.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_distance.description_float_distance"></a></span><a class="link" href="float_distance.html#math_toolkit.next_float.float_distance.description_float_distance">Description
|
||||
- float_distance</a>
|
||||
</h5>
|
||||
<p>
|
||||
Returns the distance between <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>:
|
||||
the result is always a signed integer value (stored in floating-point type
|
||||
FPT) representing the number of distinct representations between <span class="emphasis"><em>a</em></span>
|
||||
and <span class="emphasis"><em>b</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Note that
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<code class="computeroutput"><span class="identifier">float_distance</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">a</span><span class="special">)</span></code>
|
||||
always returns 0.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="computeroutput"><span class="identifier">float_distance</span><span class="special">(</span><span class="identifier">float_next</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span> <span class="identifier">a</span><span class="special">)</span></code>
|
||||
always returns -1.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<code class="computeroutput"><span class="identifier">float_distance</span><span class="special">(</span><span class="identifier">float_prior</span><span class="special">(</span><span class="identifier">a</span><span class="special">),</span> <span class="identifier">a</span><span class="special">)</span></code>
|
||||
always returns 1.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The function <code class="computeroutput"><span class="identifier">float_distance</span></code>
|
||||
is equivalent to calculating the number of ULP (Units in the Last Place)
|
||||
between <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> except that it
|
||||
returns a signed value indicating whether <code class="computeroutput"><span class="identifier">a</span>
|
||||
<span class="special">></span> <span class="identifier">b</span></code>
|
||||
or not.
|
||||
</p>
|
||||
<p>
|
||||
If the distance is too great then it may not be able to be represented as
|
||||
an exact integer by type FPT, but in practice this is unlikely to be a issue.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_prior.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_advance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,76 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Finding the Next Greater Representable Value (float_next)</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="prev" href="nextafter.html" title="Finding the Next Representable Value in a Specific Direction (nextafter)">
|
||||
<link rel="next" href="float_prior.html" title="Finding the Next Smaller Representable Value (float_prior)">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nextafter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_prior.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.next_float.float_next"></a><a class="link" href="float_next.html" title="Finding the Next Greater Representable Value (float_next)">Finding the Next
|
||||
Greater Representable Value (float_next)</a>
|
||||
</h3></div></div></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_next.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_next.synopsis"></a></span><a class="link" href="float_next.html#math_toolkit.next_float.float_next.synopsis">Synopsis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">next</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">float_next</span><span class="special">(</span><span class="identifier">FPT</span> <span class="identifier">val</span><span class="special">);</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_next.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_next.description_float_next"></a></span><a class="link" href="float_next.html#math_toolkit.next_float.float_next.description_float_next">Description
|
||||
- float_next</a>
|
||||
</h5>
|
||||
<p>
|
||||
Returns the next representable value which is greater than <span class="emphasis"><em>x</em></span>.
|
||||
If <span class="emphasis"><em>x</em></span> is non-finite then returns the result of a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>. If
|
||||
there is no such value greater than <span class="emphasis"><em>x</em></span> then returns an
|
||||
<a class="link" href="../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>.
|
||||
</p>
|
||||
<p>
|
||||
Has the same effect as
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">nextafter</span><span class="special">(</span><span class="identifier">val</span><span class="special">,</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">FPT</span><span class="special">>::</span><span class="identifier">max</span><span class="special">)());</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="nextafter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_prior.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,76 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Finding the Next Smaller Representable Value (float_prior)</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="prev" href="float_next.html" title="Finding the Next Greater Representable Value (float_next)">
|
||||
<link rel="next" href="float_distance.html" title="Calculating the Representation Distance Between Two floating-point Values (ULP) float_distance">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_next.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_distance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.next_float.float_prior"></a><a class="link" href="float_prior.html" title="Finding the Next Smaller Representable Value (float_prior)">Finding the Next
|
||||
Smaller Representable Value (float_prior)</a>
|
||||
</h3></div></div></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_prior.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_prior.synopsis"></a></span><a class="link" href="float_prior.html#math_toolkit.next_float.float_prior.synopsis">Synopsis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">next</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">float_prior</span><span class="special">(</span><span class="identifier">FPT</span> <span class="identifier">val</span><span class="special">);</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.float_prior.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.float_prior.description_float_prior"></a></span><a class="link" href="float_prior.html#math_toolkit.next_float.float_prior.description_float_prior">Description
|
||||
- float_prior</a>
|
||||
</h5>
|
||||
<p>
|
||||
Returns the next representable value which is less than <span class="emphasis"><em>x</em></span>.
|
||||
If <span class="emphasis"><em>x</em></span> is non-finite then returns the result of a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>. If
|
||||
there is no such value less than <span class="emphasis"><em>x</em></span> then returns an
|
||||
<a class="link" href="../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>.
|
||||
</p>
|
||||
<p>
|
||||
Has the same effect as
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">nextafter</span><span class="special">(</span><span class="identifier">val</span><span class="special">,</span> <span class="special">-(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">FPT</span><span class="special">>::</span><span class="identifier">max</span><span class="special">)());</span> <span class="comment">// Note most negative value -max.</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_next.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_distance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,130 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Finding the Next Representable Value in a Specific Direction (nextafter)</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="prev" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="next" href="float_next.html" title="Finding the Next Greater Representable Value (float_next)">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../next_float.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_next.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.next_float.nextafter"></a><a class="link" href="nextafter.html" title="Finding the Next Representable Value in a Specific Direction (nextafter)">Finding the Next Representable
|
||||
Value in a Specific Direction (nextafter)</a>
|
||||
</h3></div></div></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.nextafter.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.nextafter.synopsis"></a></span><a class="link" href="nextafter.html#math_toolkit.next_float.nextafter.synopsis">Synopsis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">next</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">nextafter</span><span class="special">(</span><span class="identifier">FPT</span> <span class="identifier">val</span><span class="special">,</span> <span class="identifier">FPT</span> <span class="identifier">direction</span><span class="special">);</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.nextafter.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.nextafter.description_nextafter"></a></span><a class="link" href="nextafter.html#math_toolkit.next_float.nextafter.description_nextafter">Description
|
||||
- nextafter</a>
|
||||
</h5>
|
||||
<p>
|
||||
This is an implementation of the <code class="computeroutput"><span class="identifier">nextafter</span></code>
|
||||
function included in the C99 standard. (It is also effectively an implementation
|
||||
of the C99 <code class="computeroutput"><span class="identifier">nexttoward</span></code> legacy
|
||||
function which differs only having a <code class="computeroutput"><span class="keyword">long</span>
|
||||
<span class="keyword">double</span></code> direction, and can generally
|
||||
serve in its place if required).
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
The C99 functions must use suffixes f and l to distinguish <code class="computeroutput"><span class="keyword">float</span></code> and <code class="computeroutput"><span class="keyword">long</span>
|
||||
<span class="keyword">double</span></code> versions. C++ uses the template
|
||||
mechanism instead.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
Returns the next representable value after <span class="emphasis"><em>x</em></span> in the
|
||||
direction of <span class="emphasis"><em>y</em></span>. If <code class="computeroutput"><span class="identifier">x</span>
|
||||
<span class="special">==</span> <span class="identifier">y</span></code>
|
||||
then returns <span class="emphasis"><em>x</em></span>. If <span class="emphasis"><em>x</em></span> is non-finite
|
||||
then returns the result of a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
If there is no such value in the direction of <span class="emphasis"><em>y</em></span> then
|
||||
returns an <a class="link" href="../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>.
|
||||
</p>
|
||||
<div class="warning"><table border="0" summary="Warning">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../doc/src/images/warning.png"></td>
|
||||
<th align="left">Warning</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
The template parameter FTP must be a floating-point type. An integer type,
|
||||
for example, will produce an unhelpful error message.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<div class="tip"><table border="0" summary="Tip">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="../../../../../../doc/src/images/tip.png"></td>
|
||||
<th align="left">Tip</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Nearly always, you just want the next or prior representable value, so
|
||||
instead use <code class="computeroutput"><span class="identifier">float_next</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">float_prior</span></code> below.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.nextafter.h2"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.nextafter.examples_nextafter"></a></span><a class="link" href="nextafter.html#math_toolkit.next_float.nextafter.examples_nextafter">Examples -
|
||||
nextafter</a>
|
||||
</h5>
|
||||
<p>
|
||||
The two representations using a 32-bit float either side of unity are:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">The</span> <span class="identifier">nearest</span> <span class="special">(</span><span class="identifier">exact</span><span class="special">)</span> <span class="identifier">representation</span> <span class="identifier">of</span> <span class="number">1.F</span> <span class="identifier">is</span> <span class="number">1.00000000</span>
|
||||
<span class="identifier">nextafter</span><span class="special">(</span><span class="number">1.F</span><span class="special">,</span> <span class="number">999</span><span class="special">)</span> <span class="identifier">is</span> <span class="number">1.00000012</span>
|
||||
<span class="identifier">nextafter</span><span class="special">(</span><span class="number">1</span><span class="special">/</span><span class="identifier">f</span><span class="special">,</span> <span class="special">-</span><span class="number">999</span><span class="special">)</span> <span class="identifier">is</span> <span class="number">0.99999994</span>
|
||||
|
||||
<span class="identifier">The</span> <span class="identifier">nearest</span> <span class="special">(</span><span class="keyword">not</span> <span class="identifier">exact</span><span class="special">)</span> <span class="identifier">representation</span> <span class="identifier">of</span> <span class="number">0.1F</span> <span class="identifier">is</span> <span class="number">0.100000001</span>
|
||||
<span class="identifier">nextafter</span><span class="special">(</span><span class="number">0.1F</span><span class="special">,</span> <span class="number">10</span><span class="special">)</span> <span class="identifier">is</span> <span class="number">0.100000009</span>
|
||||
<span class="identifier">nextafter</span><span class="special">(</span><span class="number">0.1F</span><span class="special">,</span> <span class="number">10</span><span class="special">)</span> <span class="identifier">is</span> <span class="number">0.099999994</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../next_float.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="float_next.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,164 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Obtaining the Size of a Unit In the Last Place - ULP</title>
|
||||
<link rel="stylesheet" href="../../math.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="../../index.html" title="Math Toolkit 2.5.1">
|
||||
<link rel="up" href="../next_float.html" title="Floating-Point Representation Distance (ULP), and Finding Adjacent Floating-Point Values">
|
||||
<link rel="prev" href="float_advance.html" title="Advancing a floating-point Value by a Specific Representation Distance (ULP) float_advance">
|
||||
<link rel="next" href="../float_comparison.html" title="Floating-point Comparison">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_advance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../float_comparison.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="math_toolkit.next_float.ulp"></a><a class="link" href="ulp.html" title="Obtaining the Size of a Unit In the Last Place - ULP">Obtaining the Size of a
|
||||
Unit In the Last Place - ULP</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Function <code class="computeroutput"><span class="identifier">ulp</span></code> gives the size
|
||||
of a unit-in-the-last-place for a specified floating-point value.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.ulp.h0"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.ulp.synopsis"></a></span><a class="link" href="ulp.html#math_toolkit.next_float.ulp.synopsis">Synopsis</a>
|
||||
</h5>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">ulp</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">ulp</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">FPT</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">FPT</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">></span>
|
||||
<span class="identifier">FPT</span> <span class="identifier">ulp</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">FPT</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&);</span>
|
||||
|
||||
<span class="special">}}</span> <span class="comment">// namespaces</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="math_toolkit.next_float.ulp.h1"></a>
|
||||
<span class="phrase"><a name="math_toolkit.next_float.ulp.description_ulp"></a></span><a class="link" href="ulp.html#math_toolkit.next_float.ulp.description_ulp">Description
|
||||
- ulp</a>
|
||||
</h5>
|
||||
<p>
|
||||
Returns one <a href="http://en.wikipedia.org/wiki/Unit_in_the_last_place" target="_top">unit
|
||||
in the last place</a> of <span class="emphasis"><em>x</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
Corner cases are handled as followes:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
If the argument is a NaN, then raises a <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
If the argument is an infinity, then raises an <a class="link" href="../error_handling.html#math_toolkit.error_handling.overflow_error">overflow_error</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
If the argument is zero then returns the smallest representable value:
|
||||
for example for type <code class="computeroutput"><span class="keyword">double</span></code>
|
||||
this would be either <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="keyword">double</span><span class="special">>::</span><span class="identifier">min</span><span class="special">()</span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="keyword">double</span><span class="special">>::</span><span class="identifier">denorm_min</span><span class="special">()</span></code> depending whether denormals are supported
|
||||
(which have the values 2.<code class="computeroutput"><span class="number">2250738585072014e-308</span></code>
|
||||
and <code class="computeroutput"><span class="number">4.9406564584124654e-324</span></code>
|
||||
respectively).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
If the result is too small to represent, then returns the smallest representable
|
||||
value.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Always returns a positive value such that <code class="computeroutput"><span class="identifier">ulp</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">ulp</span><span class="special">(-</span><span class="identifier">x</span><span class="special">)</span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
<span class="bold"><strong>Important:</strong></span> The behavior of this function
|
||||
is aligned to that of <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#ulp%28double%29" target="_top">Java's
|
||||
ulp function</a>, please note however that this function should only
|
||||
ever be used for rough and ready calculations as there are enough corner
|
||||
cases to trap even careful programmers. In particular:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
The function is asymetrical, which is to say, given <code class="computeroutput"><span class="identifier">u</span>
|
||||
<span class="special">=</span> <span class="identifier">ulp</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> if <code class="computeroutput"><span class="identifier">x</span>
|
||||
<span class="special">></span> <span class="number">0</span></code>
|
||||
then <code class="computeroutput"><span class="identifier">x</span> <span class="special">+</span>
|
||||
<span class="identifier">u</span></code> is the next floating-point
|
||||
value, but <code class="computeroutput"><span class="identifier">x</span> <span class="special">-</span>
|
||||
<span class="identifier">u</span></code> is not necessarily the previous
|
||||
value. Similarly, if <code class="computeroutput"><span class="identifier">x</span> <span class="special"><</span> <span class="number">0</span></code>
|
||||
then <code class="computeroutput"><span class="identifier">x</span> <span class="special">-</span>
|
||||
<span class="identifier">u</span></code> is the previous floating-point
|
||||
value, but <code class="computeroutput"><span class="identifier">x</span> <span class="special">+</span>
|
||||
<span class="identifier">u</span></code> is not necessarily the next
|
||||
value. The corner cases occur at power of 2 boundaries.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
When the argument becomes very small, it may be that there is no floating-point
|
||||
value that represents one ULP. Whether this is the case or not depends
|
||||
not only on whether the hardware may <span class="emphasis"><em>sometimes</em></span> support
|
||||
denormals (as signalled by <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">FPT</span><span class="special">>::</span><span class="identifier">has_denorm</span></code>),
|
||||
but also whether these are currently enabled at runtime (for example
|
||||
on SSE hardware, the DAZ or FTZ flags will disable denormal support).
|
||||
In this situation, the <code class="computeroutput"><span class="identifier">ulp</span></code>
|
||||
function may return a value that is many orders of magnitude too large.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
In light of the issues above, we recomend that:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
To move between adjacent floating-point values always use <a class="link" href="float_next.html" title="Finding the Next Greater Representable Value (float_next)">float_next</a>,
|
||||
<a class="link" href="float_prior.html" title="Finding the Next Smaller Representable Value (float_prior)">float_prior</a>
|
||||
or <a class="link" href="nextafter.html" title="Finding the Next Representable Value in a Specific Direction (nextafter)">nextafter</a>
|
||||
(<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">nextafter</span></code> is another candidate, but
|
||||
our experience is that this also often breaks depending which optimizations
|
||||
and hardware flags are in effect).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
To move several floating-point values away use <a class="link" href="float_advance.html" title="Advancing a floating-point Value by a Specific Representation Distance (ULP) float_advance">float_advance</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
To calculate the edit distance between two floats use <a href="../../../../../../libs/math/doc/html/math_toolkit/next_float/float_distance.html" target="_top">Boost.Math
|
||||
float_distance</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
There is none the less, one important use case for this function:
|
||||
</p>
|
||||
<p>
|
||||
If it is known that the true result of some function is x<sub>t</sub> and the calculated
|
||||
result is x<sub>c</sub>, then the error measured in ulp is simply <code class="literal">fabs(x<sub>t</sub> -
|
||||
x<sub>c</sub>) / ulp(x<sub>t</sub>)</code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
|
||||
Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
|
||||
Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
|
||||
Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="float_advance.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../next_float.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../float_comparison.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user