3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Greatest-width floating-point typedef</title>
5 <link rel="stylesheet" href="../math.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../index.html" title="Math Toolkit 2.5.2">
8 <link rel="up" href="../cstdfloat.html" title="Chapter 3. Specified-width floating-point typedefs">
9 <link rel="prev" href="fastest_typdefs.html" title="Fastest floating-point typedefs">
10 <link rel="next" href="macros.html" title="Floating-Point Constant Macros">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <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>
26 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
27 <a name="math_toolkit.greatest_typdefs"></a><a class="link" href="greatest_typdefs.html" title="Greatest-width floating-point typedef">Greatest-width floating-point
29 </h2></div></div></div>
31 The <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">floatmax_t</span></code>
32 designates a floating-point type capable of representing any value of any floating-point
33 type in a given platform most precisely.
36 The greatest-width <code class="computeroutput"><span class="keyword">typedef</span></code> is
37 provided for all platforms, but, of course, the size may vary.
40 To provide floating-point <span class="bold"><strong>constants</strong></span> most precisely
41 representable for a <code class="computeroutput"><span class="identifier">floatmax_t</span></code>
42 type, use the macro <code class="computeroutput"><span class="identifier">BOOST_FLOATMAX_C</span></code>.
45 For example, replace a constant <code class="computeroutput"><span class="number">123.4567890123456789012345678901234567890</span></code>
48 <pre class="programlisting"><span class="identifier">BOOST_FLOATMAX_C</span><span class="special">(</span><span class="number">123.4567890123456789012345678901234567890</span><span class="special">)</span>
51 If, for example, <code class="computeroutput"><span class="identifier">floatmax_t</span></code>
52 is <code class="computeroutput"><span class="identifier">float64_t</span></code> then the result
53 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>
54 then the result will be equivalent to a <code class="computeroutput"><span class="identifier">quad</span>
55 <span class="identifier">type</span></code> suffixed with Q (assuming, of
56 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>)
60 If we display with <code class="computeroutput"><span class="identifier">max_digits10</span></code>,
61 the maximum possibly significant decimal digits:
63 <pre class="programlisting"><span class="preprocessor">#ifdef</span> <span class="identifier">BOOST_FLOAT32_C</span>
64 <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>
65 <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>
66 <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>
67 <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>
68 <span class="comment">// BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787</span>
69 <span class="preprocessor">#endif</span>
72 then on a 128-bit platform (GCC 4.8.1 or higher with quadmath):
74 <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>
75 <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>
76 <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>
77 <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>
80 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
81 <td align="left"></td>
82 <td align="right"><div class="copyright-footer">Copyright © 2006-2010, 2012-2014 Nikhar Agrawal,
83 Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
84 Holin, Bruno Lalande, John Maddock, Jeremy Murphy, Johan Råde, Gautam Sewani,
85 Benjamin Sobotta, Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
86 Distributed under the Boost Software License, Version 1.0. (See accompanying
87 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>)
92 <div class="spirit-nav">
93 <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>