72e469da0a
[CI SKIP]
98 lines
8.5 KiB
HTML
98 lines
8.5 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
<title>Greatest-width floating-point typedef</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.11.0">
|
|
<link rel="up" href="../cstdfloat.html" title="Chapter 3. Specified-width floating-point typedefs">
|
|
<link rel="prev" href="fastest_typdefs.html" title="Fastest floating-point typedefs">
|
|
<link rel="next" href="macros.html" title="Floating-Point Constant Macros">
|
|
</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="fastest_typdefs.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../cstdfloat.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="macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|
<a name="math_toolkit.greatest_typdefs"></a><a class="link" href="greatest_typdefs.html" title="Greatest-width floating-point typedef">Greatest-width floating-point
|
|
typedef</a>
|
|
</h2></div></div></div>
|
|
<p>
|
|
The <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">floatmax_t</span></code>
|
|
designates a floating-point type capable of representing any value of any floating-point
|
|
type in a given platform most precisely.
|
|
</p>
|
|
<p>
|
|
The greatest-width <code class="computeroutput"><span class="keyword">typedef</span></code> is
|
|
provided for all platforms, but, of course, the size may vary.
|
|
</p>
|
|
<p>
|
|
To provide floating-point <span class="bold"><strong>constants</strong></span> most precisely
|
|
representable for a <code class="computeroutput"><span class="identifier">floatmax_t</span></code>
|
|
type, use the macro <code class="computeroutput"><span class="identifier">BOOST_FLOATMAX_C</span></code>.
|
|
</p>
|
|
<p>
|
|
For example, replace a constant <code class="computeroutput"><span class="number">123.4567890123456789012345678901234567890</span></code>
|
|
with
|
|
</p>
|
|
<pre class="programlisting"><span class="identifier">BOOST_FLOATMAX_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span>
|
|
</pre>
|
|
<p>
|
|
If, for example, <code class="computeroutput"><span class="identifier">floatmax_t</span></code>
|
|
is <code class="computeroutput"><span class="identifier">float64_t</span></code> then the result
|
|
will be equivalent to a <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code> suffixed with L, but if <code class="computeroutput"><span class="identifier">floatmax_t</span></code> is <code class="computeroutput"><span class="identifier">float128_t</span></code>
|
|
then the result will be equivalent to a <code class="computeroutput"><span class="identifier">quad</span>
|
|
<span class="identifier">type</span></code> suffixed with Q (assuming, of
|
|
course, that <code class="computeroutput"><span class="identifier">float128_t</span></code> (<code class="computeroutput"><span class="identifier">__float128</span></code> or <code class="computeroutput"><span class="identifier">Quad</span></code>)
|
|
is supported).
|
|
</p>
|
|
<p>
|
|
If we display with <code class="computeroutput"><span class="identifier">max_digits10</span></code>,
|
|
the maximum possibly significant decimal digits:
|
|
</p>
|
|
<pre class="programlisting"><span class="preprocessor">#ifdef</span> <span class="identifier">BOOST_FLOAT32_C</span>
|
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">.</span><span class="identifier">precision</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">max_digits10</span><span class="special"><</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">float32_t</span><span class="special">>());</span> <span class="comment">// Show all significant decimal digits,</span>
|
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">.</span><span class="identifier">setf</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios</span><span class="special">::</span><span class="identifier">showpoint</span><span class="special">);</span> <span class="comment">// including all significant trailing zeros.</span>
|
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = "</span>
|
|
<span class="special"><<</span> <span class="identifier">BOOST_FLOAT32_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
|
<span class="comment">// BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787</span>
|
|
<span class="preprocessor">#endif</span>
|
|
</pre>
|
|
<p>
|
|
then on a 128-bit platform (GCC 4.8.1 or higher with quadmath):
|
|
</p>
|
|
<pre class="programlisting"><span class="identifier">BOOST_FLOAT32_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span> <span class="special">=</span> <span class="number">123.456787</span>
|
|
<span class="identifier">BOOST_FLOAT64_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span> <span class="special">=</span> <span class="number">123.45678901234568</span>
|
|
<span class="identifier">BOOST_FLOAT80_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span> <span class="special">=</span> <span class="number">123.456789012345678903</span>
|
|
<span class="identifier">BOOST_FLOAT128_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span> <span class="special">=</span> <span class="number">123.456789012345678901234567890123453</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-2019 Nikhar
|
|
Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos,
|
|
Hubert Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Matthew Pulver, Johan
|
|
Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, 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="fastest_typdefs.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../cstdfloat.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="macros.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|