mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-02-02 21:12:11 +00:00
Merge branch 'develop' of https://github.com/boostorg/multiprecision into develop
This commit is contained in:
@@ -780,3 +780,4 @@ script:
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id1213386"></a>Function Index</h3></div></div></div>
|
||||
<a name="id1217111"></a>Function Index</h3></div></div></div>
|
||||
<p><a class="link" href="s01.html#idx_id_0">A</a> <a class="link" href="s01.html#idx_id_1">B</a> <a class="link" href="s01.html#idx_id_2">C</a> <a class="link" href="s01.html#idx_id_3">D</a> <a class="link" href="s01.html#idx_id_4">E</a> <a class="link" href="s01.html#idx_id_5">F</a> <a class="link" href="s01.html#idx_id_7">H</a> <a class="link" href="s01.html#idx_id_8">I</a> <a class="link" href="s01.html#idx_id_9">L</a> <a class="link" href="s01.html#idx_id_10">M</a> <a class="link" href="s01.html#idx_id_11">N</a> <a class="link" href="s01.html#idx_id_12">O</a> <a class="link" href="s01.html#idx_id_13">P</a> <a class="link" href="s01.html#idx_id_14">R</a> <a class="link" href="s01.html#idx_id_15">S</a> <a class="link" href="s01.html#idx_id_16">T</a> <a class="link" href="s01.html#idx_id_18">V</a> <a class="link" href="s01.html#idx_id_19">X</a> <a class="link" href="s01.html#idx_id_20">Z</a></p>
|
||||
<div class="variablelist"><dl class="variablelist">
|
||||
<dt>
|
||||
@@ -155,6 +155,10 @@
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">constexpr</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">std::numeric_limits<> constants</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">convert_to</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li></ul></div>
|
||||
</li>
|
||||
@@ -192,6 +196,7 @@
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/gmp_float.html" title="gmp_float"><span class="index-entry-level-1">gmp_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/ints/gmp_int.html" title="gmp_int"><span class="index-entry-level-1">gmp_int</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/rational/gmp_rational.html" title="gmp_rational"><span class="index-entry-level-1">gmp_rational</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/lits.html" title="Literal Types and constexpr Support"><span class="index-entry-level-1">Literal Types and constexpr Support</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/complex/mpc_complex.html" title="mpc_complex"><span class="index-entry-level-1">mpc_complex</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/interval/mpfi.html" title="mpfi_float"><span class="index-entry-level-1">mpfi_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/mpfr_float.html" title="mpfr_float"><span class="index-entry-level-1">mpfr_float</span></a></p></li>
|
||||
@@ -227,6 +232,10 @@
|
||||
</dt>
|
||||
<dd><div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">e</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">Mixed Precision Arithmetic</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">empty</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/interval/mpfi.html" title="mpfi_float"><span class="index-entry-level-1">mpfi_float</span></a></p></li></ul></div>
|
||||
</li>
|
||||
@@ -613,7 +622,7 @@
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">infinity</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li></ul></div>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">integer_modulus</span></p>
|
||||
@@ -909,7 +918,7 @@
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/gen_int.html" title="Generic Integer Operations"><span class="index-entry-level-1">Generic Integer Operations</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../map/hist.html" title="History"><span class="index-entry-level-1">History</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
@@ -983,7 +992,7 @@
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/cpp_bin_float_ref.html" title="cpp_bin_float"><span class="index-entry-level-1">cpp_bin_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
</ul></div></dd>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id1219854"></a>Class Index</h3></div></div></div>
|
||||
<a name="id1224189"></a>Class Index</h3></div></div></div>
|
||||
<p><a class="link" href="s02.html#idx_id_23">C</a> <a class="link" href="s02.html#idx_id_24">D</a> <a class="link" href="s02.html#idx_id_25">E</a> <a class="link" href="s02.html#idx_id_26">F</a> <a class="link" href="s02.html#idx_id_27">G</a> <a class="link" href="s02.html#idx_id_29">I</a> <a class="link" href="s02.html#idx_id_30">L</a> <a class="link" href="s02.html#idx_id_31">M</a> <a class="link" href="s02.html#idx_id_32">N</a> <a class="link" href="s02.html#idx_id_37">T</a></p>
|
||||
<div class="variablelist"><dl class="variablelist">
|
||||
<dt>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id1220428"></a>Typedef Index</h3></div></div></div>
|
||||
<a name="id1226590"></a>Typedef Index</h3></div></div></div>
|
||||
<p><a class="link" href="s03.html#idx_id_43">B</a> <a class="link" href="s03.html#idx_id_44">C</a> <a class="link" href="s03.html#idx_id_47">F</a> <a class="link" href="s03.html#idx_id_50">I</a> <a class="link" href="s03.html#idx_id_51">L</a> <a class="link" href="s03.html#idx_id_52">M</a> <a class="link" href="s03.html#idx_id_57">S</a> <a class="link" href="s03.html#idx_id_58">T</a> <a class="link" href="s03.html#idx_id_59">U</a> <a class="link" href="s03.html#idx_id_60">V</a></p>
|
||||
<div class="variablelist"><dl class="variablelist">
|
||||
<dt>
|
||||
@@ -147,8 +147,8 @@
|
||||
<p><span class="index-entry-level-0">cpp_dec_float_50</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/cpp_dec_float.html" title="cpp_dec_float"><span class="index-entry-level-1">cpp_dec_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">std::numeric_limits<> constants</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/ints/cpp_int.html" title="cpp_int"><span class="index-entry-level-0">cpp_int</span></a></p></li>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="id1224836"></a>Index</h3></div></div></div>
|
||||
<a name="id1228112"></a>Index</h3></div></div></div>
|
||||
<p><a class="link" href="s04.html#idx_id_63">A</a> <a class="link" href="s04.html#idx_id_64">B</a> <a class="link" href="s04.html#idx_id_65">C</a> <a class="link" href="s04.html#idx_id_66">D</a> <a class="link" href="s04.html#idx_id_67">E</a> <a class="link" href="s04.html#idx_id_68">F</a> <a class="link" href="s04.html#idx_id_69">G</a> <a class="link" href="s04.html#idx_id_70">H</a> <a class="link" href="s04.html#idx_id_71">I</a> <a class="link" href="s04.html#idx_id_72">L</a> <a class="link" href="s04.html#idx_id_73">M</a> <a class="link" href="s04.html#idx_id_74">N</a> <a class="link" href="s04.html#idx_id_75">O</a> <a class="link" href="s04.html#idx_id_76">P</a> <a class="link" href="s04.html#idx_id_77">R</a> <a class="link" href="s04.html#idx_id_78">S</a> <a class="link" href="s04.html#idx_id_79">T</a> <a class="link" href="s04.html#idx_id_80">U</a> <a class="link" href="s04.html#idx_id_81">V</a> <a class="link" href="s04.html#idx_id_82">X</a> <a class="link" href="s04.html#idx_id_83">Z</a></p>
|
||||
<div class="variablelist"><dl class="variablelist">
|
||||
<dt>
|
||||
@@ -295,6 +295,10 @@
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">constexpr</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">std::numeric_limits<> constants</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">Constructing and Interconverting Between Number Types</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/conversions.html" title="Constructing and Interconverting Between Number Types"><span class="index-entry-level-1">i</span></a></p></li></ul></div>
|
||||
</li>
|
||||
@@ -416,8 +420,8 @@
|
||||
<p><span class="index-entry-level-0">cpp_dec_float_50</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/cpp_dec_float.html" title="cpp_dec_float"><span class="index-entry-level-1">cpp_dec_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">std::numeric_limits<> constants</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
@@ -482,6 +486,7 @@
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/gmp_float.html" title="gmp_float"><span class="index-entry-level-1">gmp_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/ints/gmp_int.html" title="gmp_int"><span class="index-entry-level-1">gmp_int</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/rational/gmp_rational.html" title="gmp_rational"><span class="index-entry-level-1">gmp_rational</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/lits.html" title="Literal Types and constexpr Support"><span class="index-entry-level-1">Literal Types and constexpr Support</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/complex/mpc_complex.html" title="mpc_complex"><span class="index-entry-level-1">mpc_complex</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/interval/mpfi.html" title="mpfi_float"><span class="index-entry-level-1">mpfi_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/mpfr_float.html" title="mpfr_float"><span class="index-entry-level-1">mpfr_float</span></a></p></li>
|
||||
@@ -525,6 +530,10 @@
|
||||
</dt>
|
||||
<dd><div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">e</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">Mixed Precision Arithmetic</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">empty</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/interval/mpfi.html" title="mpfi_float"><span class="index-entry-level-1">mpfi_float</span></a></p></li></ul></div>
|
||||
</li>
|
||||
@@ -1013,7 +1022,7 @@
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">infinity</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li></ul></div>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">Input Output</span></p>
|
||||
@@ -1162,7 +1171,10 @@
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">Literal Types and constexpr Support</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/lits.html" title="Literal Types and constexpr Support"><span class="index-entry-level-1">BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL</span></a></p></li></ul></div>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/lits.html" title="Literal Types and constexpr Support"><span class="index-entry-level-1">BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/lits.html" title="Literal Types and constexpr Support"><span class="index-entry-level-1">data</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">llrint</span></p>
|
||||
@@ -1243,6 +1255,7 @@
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">a</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">add</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">e</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">i</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">multiply</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/mixed.html" title="Mixed Precision Arithmetic"><span class="index-entry-level-1">subtract</span></a></p></li>
|
||||
@@ -1722,7 +1735,7 @@
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/gen_int.html" title="Generic Integer Operations"><span class="index-entry-level-1">Generic Integer Operations</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../map/hist.html" title="History"><span class="index-entry-level-1">History</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
@@ -1734,18 +1747,7 @@
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/floats/mpfr_float.html" title="mpfr_float"><span class="index-entry-level-1">mpfr_float</span></a></p></li></ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">std::numeric_limits<> constants</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">bits</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">cpp_dec_float_50</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">digits10</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">float128</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">type</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">zero</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">std::numeric_limits<> functions</span></p>
|
||||
<p><span class="index-entry-level-0">std :: numeric_limits <> functions</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">cpp_dec_float_50</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">infinity</span></a></p></li>
|
||||
@@ -1754,6 +1756,18 @@
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">std::numeric_limits<> constants</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">bits</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">constexpr</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">cpp_dec_float_50</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">digits10</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">float128</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">type</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/constants.html" title="std::numeric_limits<> constants"><span class="index-entry-level-1">zero</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
<p><span class="index-entry-level-0">str</span></p>
|
||||
<div class="index"><ul class="index" style="list-style-type: none; "><li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li></ul></div>
|
||||
</li>
|
||||
@@ -1879,7 +1893,7 @@
|
||||
<div class="index"><ul class="index" style="list-style-type: none; ">
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/cpp_bin_float_ref.html" title="cpp_bin_float"><span class="index-entry-level-1">cpp_bin_float</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../ref/number.html" title="number"><span class="index-entry-level-1">number</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std::numeric_limits<> functions</span></a></p></li>
|
||||
<li class="listitem" style="list-style-type: none"><p><a class="link" href="../tut/limits/functions.html" title="std::numeric_limits<> functions"><span class="index-entry-level-1">std :: numeric_limits <> functions</span></a></p></li>
|
||||
</ul></div>
|
||||
</li>
|
||||
<li class="listitem" style="list-style-type: none">
|
||||
|
||||
@@ -34,27 +34,29 @@
|
||||
The big number types in Multiprecision can be used with a wide selection of
|
||||
basic mathematical operations, elementary transcendental functions as well
|
||||
as the functions in Boost.Math. The Multiprecision types can also interoperate
|
||||
with the __fundamental types in C++ using clearly defined conversion rules.
|
||||
This allows Boost.Multiprecision to be used for all kinds of mathematical calculations
|
||||
with any <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental
|
||||
(built-in) type</a> in C++ using clearly defined conversion rules. This
|
||||
allows Boost.Multiprecision to be used for all kinds of mathematical calculations
|
||||
involving integer, rational and floating-point types requiring extended range
|
||||
and precision.
|
||||
</p>
|
||||
<p>
|
||||
Multiprecision consists of a generic interface to the mathematics of large
|
||||
numbers as well as a selection of big number back ends, with support for integer,
|
||||
numbers as well as a selection of big number back-ends, with support for integer,
|
||||
rational, floating-point, and complex types. Boost.Multiprecision provides
|
||||
a selection of back ends provided off-the-rack in including interfaces to GMP,
|
||||
a selection of back-ends provided off-the-rack in including interfaces to GMP,
|
||||
MPFR, MPIR, MPC, TomMath as well as its own collection of Boost-licensed, header-only
|
||||
back ends for integers, rationals and floats. In addition, user-defined back
|
||||
ends can be created and used with the interface of Multiprecision, provided
|
||||
the class implementation adheres to the necessary <a class="link" href="ref/backendconc.html" title="Backend Requirements">concepts</a>.
|
||||
back-ends for integers, rationals and floats. In addition, user-defined back-ends
|
||||
can be created and used with the interface of Multiprecision, provided the
|
||||
class implementation adheres to the necessary <a class="link" href="ref/backendconc.html" title="Backend Requirements">concepts</a>.
|
||||
</p>
|
||||
<p>
|
||||
Depending upon the number type, precision may be arbitrarily large (limited
|
||||
only by available memory), fixed at compile time (for example 50 or 100 decimal
|
||||
only by available memory), fixed at compile time (for example, 50 or 100 decimal
|
||||
digits), or a variable controlled at run-time by member functions. The types
|
||||
are <a href="https://en.wikipedia.org/wiki/Expression_templates" target="_top">expression
|
||||
template</a> -enabled for better performance than naive user-defined types.
|
||||
templates</a> - enabled for better performance than naive user-defined
|
||||
types.
|
||||
</p>
|
||||
<p>
|
||||
The Multiprecision library comes in two distinct parts:
|
||||
@@ -77,17 +79,50 @@
|
||||
back-ends rely on 3rd party libraries, but a header-only Boost license version
|
||||
is always available (if somewhat slower).
|
||||
</p>
|
||||
<h6>
|
||||
<a name="boost_multiprecision.intro.h0"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.intro.getting_started"></a></span><a class="link" href="intro.html#boost_multiprecision.intro.getting_started">Getting
|
||||
started with Boost.Multiprecision</a>
|
||||
</h6>
|
||||
<p>
|
||||
Should you just wish to cut to the chase and use a fully Boost-licensed number
|
||||
type, then skip to <a class="link" href="tut/ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
for multiprecision integers, <a class="link" href="tut/rational/cpp_rational.html" title="cpp_rational">cpp_rational</a>
|
||||
for rational types, <a class="link" href="tut/floats/cpp_dec_float.html" title="cpp_dec_float">cpp_dec_float</a>
|
||||
for multiprecision floating-point types and <a class="link" href="tut/complex/cpp_complex.html" title="cpp_complex">cpp_complex</a>
|
||||
for complex types.
|
||||
Should you just wish to 'cut to the chase' just to get bigger integers or bigger
|
||||
and more precise reals as simply and portably as possible, close to 'drop-in'
|
||||
replacements for the <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental
|
||||
(built-in) type</a> anlogs, then use a fully Boost-licensed number type,
|
||||
and skip to:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a class="link" href="tut/ints/cpp_int.html" title="cpp_int">cpp_int</a> for
|
||||
multiprecision integers,
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="tut/rational/cpp_rational.html" title="cpp_rational">cpp_rational</a>
|
||||
for rational types,
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="tut/floats/cpp_bin_float.html" title="cpp_bin_float">cpp_bin_float</a>
|
||||
and <a class="link" href="tut/floats/cpp_dec_float.html" title="cpp_dec_float">cpp_dec_float</a>
|
||||
for multiprecision floating-point types,
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<a class="link" href="tut/complex/cpp_complex.html" title="cpp_complex">cpp_complex</a>
|
||||
for complex types.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The library is very often used via one of the predefined convenience <code class="computeroutput"><span class="keyword">typedef</span></code>s like <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">int128_t</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">cpp_bin_float_quad</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
The library is often used via one of the predefined typedefs: for example if
|
||||
you wanted an <a href="http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic" target="_top">arbitrary
|
||||
For example, if you want a signed, 128-bit fixed size integer:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">cpp_int</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <span class="comment">// Integer types.</span>
|
||||
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">int128_t</span> <span class="identifier">my_128_bit_int</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Alternatively, and more adventurously, if you wanted an <a href="http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic" target="_top">arbitrary
|
||||
precision</a> integer type using <a href="http://gmplib.org" target="_top">GMP</a>
|
||||
as the underlying implementation then you could use:
|
||||
</p>
|
||||
@@ -96,27 +131,37 @@
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">mpz_int</span> <span class="identifier">myint</span><span class="special">;</span> <span class="comment">// Arbitrary precision integer type.</span>
|
||||
</pre>
|
||||
<p>
|
||||
Alternatively, you can compose your own multiprecision type, by combining
|
||||
Or for a simple, portable 128-bit floating-point close to a drop-in for a
|
||||
<a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental (built-in)
|
||||
type</a> like <code class="computeroutput"><span class="keyword">double</span></code>, usually
|
||||
64-bit
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">cpp_bin_float</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||||
|
||||
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">cpp_bin_float_quad</span> <span class="identifier">my_quad_real</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Alternatively, you can compose your own 'custom' multiprecision type, by combining
|
||||
<code class="computeroutput"><span class="identifier">number</span></code> with one of the predefined
|
||||
back-end types. For example, suppose you wanted a 300 decimal digit floating-point
|
||||
type based on the <a href="http://www.mpfr.org" target="_top">MPFR</a> library. In
|
||||
this case, there's no predefined typedef with that level of precision, so instead
|
||||
we compose our own:
|
||||
this case, there's no predefined <code class="computeroutput"><span class="keyword">typedef</span></code>
|
||||
with that level of precision, so instead we compose our own:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">mpfr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <span class="comment">// Defines the Backend type that wraps MPFR</span>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">mpfr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <span class="comment">// Defines the Backend type that wraps MPFR.</span>
|
||||
|
||||
<span class="keyword">namespace</span> <span class="identifier">mp</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">;</span> <span class="comment">// Reduce the typing a bit later...</span>
|
||||
|
||||
<span class="keyword">typedef</span> <span class="identifier">mp</span><span class="special">::</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">mp</span><span class="special">::</span><span class="identifier">mpfr_float_backend</span><span class="special"><</span><span class="number">300</span><span class="special">></span> <span class="special">></span> <span class="identifier">my_float</span><span class="special">;</span>
|
||||
|
||||
<span class="identifier">my_float</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">c</span><span class="special">;</span> <span class="comment">// These variables have 300 decimal digits precision</span>
|
||||
<span class="identifier">my_float</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">c</span><span class="special">;</span> <span class="comment">// These variables have 300 decimal digits precision.</span>
|
||||
</pre>
|
||||
<p>
|
||||
We can repeat the above example, but with the expression templates disabled
|
||||
(for faster compile times, but slower runtimes) by passing a second template
|
||||
argument to <code class="computeroutput"><span class="identifier">number</span></code>:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">mpfr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <span class="comment">// Defines the Backend type that wraps MPFR</span>
|
||||
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">mpfr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <span class="comment">// Defines the Backend type that wraps MPFR.</span>
|
||||
|
||||
<span class="keyword">namespace</span> <span class="identifier">mp</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">;</span> <span class="comment">// Reduce the typing a bit later...</span>
|
||||
|
||||
@@ -160,7 +205,7 @@
|
||||
<span class="identifier">b</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">*</span> <span class="number">3.14</span><span class="special">;</span> <span class="comment">// Error, no operator overload if the conversion would be explicit.</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="boost_multiprecision.intro.h0"></a>
|
||||
<a name="boost_multiprecision.intro.h1"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.intro.move_semantics"></a></span><a class="link" href="intro.html#boost_multiprecision.intro.move_semantics">Move
|
||||
Semantics</a>
|
||||
</h5>
|
||||
@@ -200,7 +245,7 @@
|
||||
library containers.
|
||||
</p>
|
||||
<h5>
|
||||
<a name="boost_multiprecision.intro.h1"></a>
|
||||
<a name="boost_multiprecision.intro.h2"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.intro.expression_templates"></a></span><a class="link" href="intro.html#boost_multiprecision.intro.expression_templates">Expression
|
||||
Templates</a>
|
||||
</h5>
|
||||
@@ -224,15 +269,15 @@
|
||||
<span class="emphasis"><em>unmentionable-type</em></span> <span class="keyword">operator</span> <span class="special">*</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>&</span> <span class="identifier">b</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Where the "unmentionable" return type is an implementation detail
|
||||
that, rather than containing the result of the multiplication, contains instructions
|
||||
on how to compute the result. In effect it's just a pair of references to the
|
||||
arguments of the function, plus some compile-time information that stores what
|
||||
the operation is.
|
||||
Where the '<span class="emphasis"><em>unmentionable</em></span>' return type is an implementation
|
||||
detail that, rather than containing the result of the multiplication, contains
|
||||
instructions on how to compute the result. In effect it's just a pair of references
|
||||
to the arguments of the function, plus some compile-time information that stores
|
||||
what the operation is.
|
||||
</p>
|
||||
<p>
|
||||
The great advantage of this method is the <span class="emphasis"><em>elimination of temporaries</em></span>:
|
||||
for example the "naive" implementation of <code class="computeroutput"><span class="keyword">operator</span><span class="special">*</span></code> above, requires one temporary for computing
|
||||
for example, the "naive" implementation of <code class="computeroutput"><span class="keyword">operator</span><span class="special">*</span></code> above, requires one temporary for computing
|
||||
the result, and at least another one to return it. It's true that sometimes
|
||||
this overhead can be reduced by using move-semantics, but it can't be eliminated
|
||||
completely. For example, lets suppose we're evaluating a polynomial via Horner's
|
||||
@@ -374,28 +419,29 @@
|
||||
</p>
|
||||
<p>
|
||||
In fact it is particularly easy to create dangling references by mixing expression
|
||||
templates with the auto keyword, for example:
|
||||
templates with the <code class="computeroutput"><span class="keyword">auto</span></code> keyword,
|
||||
for example:
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">auto</span> <span class="identifier">val</span>
|
||||
<span class="special">=</span> <span class="identifier">cpp_dec_float_50</span><span class="special">(</span><span class="string">"23.1"</span><span class="special">)</span> <span class="special">*</span> <span class="number">100</span><span class="special">;</span></code>
|
||||
</p>
|
||||
<p>
|
||||
In this situation the integer literal is stored directly in the expression
|
||||
template - so its use is OK here - but the cpp_dec_float_50 temporary is
|
||||
stored by reference and then destructed when the statement completes leaving
|
||||
a dangling reference.
|
||||
In this situation, the integer literal is stored directly in the expression
|
||||
template - so its use is OK here - but the <code class="computeroutput"><span class="identifier">cpp_dec_float_50</span></code>
|
||||
temporary is stored by reference and then destructed when the statement completes,
|
||||
leaving a dangling reference.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong><span class="emphasis"><em>If in doubt, do not ever mix expression templates
|
||||
with the auto keyword.</em></span></strong></span>
|
||||
with the <code class="computeroutput"><span class="keyword">auto</span></code> keyword.</em></span></strong></span>
|
||||
</p>
|
||||
</td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
And finally... the performance improvements from an expression template library
|
||||
like this are often not as dramatic as the reduction in number of temporaries
|
||||
would suggest. For example if we compare this library with <a href="http://math.berkeley.edu/~wilken/code/gmpfrxx/" target="_top">mpfr_class</a>
|
||||
would suggest. For example, if we compare this library with <a href="http://math.berkeley.edu/~wilken/code/gmpfrxx/" target="_top">mpfr_class</a>
|
||||
and <a href="http://www.holoborodko.com/pavel/mpfr/" target="_top">mpreal</a>, with
|
||||
all three using the underlying <a href="http://www.mpfr.org" target="_top">MPFR</a>
|
||||
library at 50 decimal digits precision then we see the following typical results
|
||||
@@ -720,7 +766,7 @@
|
||||
<div id="ftn.boost_multiprecision.intro.f0" class="footnote"><p><a href="#boost_multiprecision.intro.f0" class="para"><sup class="para">[1] </sup></a>
|
||||
The actual number generated will depend on the compiler, how well it optimizes
|
||||
the code, and whether it supports rvalue references. The number of 11 temporaries
|
||||
was generated with Visual C++ 10
|
||||
was generated with Visual C++ 2010.
|
||||
</p></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -101,7 +101,8 @@
|
||||
This was deemed not to be practical: these algorithms are intimately
|
||||
tied to the actual data representation used.
|
||||
</p></dd>
|
||||
<dt><span class="term">How do I choose between Boost.Multiprecision cpp_bin_50 and cpp_dec_50?</span></dt>
|
||||
<dt><span class="term">How do I choose between Boost.Multiprecision <code class="computeroutput"><span class="identifier">cpp_bin_50</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">cpp_dec_50</span></code>?</span></dt>
|
||||
<dd>
|
||||
<p>
|
||||
Unless you have a specific reason to choose <code class="computeroutput"><span class="identifier">cpp_dec_</span></code>,
|
||||
|
||||
@@ -91,7 +91,8 @@
|
||||
<dt><span class="section"><a href="tut/primetest.html">Primality Testing</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/lits.html">Literal Types and <code class="computeroutput"><span class="keyword">constexpr</span></code> Support</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/import_export.html">Importing and
|
||||
Exporting Data to and from cpp_int and cpp_bin_float</a></span></dt>
|
||||
Exporting Data to and from <code class="computeroutput"><span class="identifier">cpp_int</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">cpp_bin_float</span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="tut/rounding.html">Rounding Rules for
|
||||
Conversions</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/mixed.html">Mixed Precision Arithmetic</a></span></dt>
|
||||
@@ -102,8 +103,7 @@
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="tut/limits/constants.html">std::numeric_limits<>
|
||||
constants</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/limits/functions.html">std::numeric_limits<>
|
||||
functions</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/limits/functions.html"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><></span></code> functions</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/limits/limits32.html">Numeric limits
|
||||
for 32-bit platform</a></span></dt>
|
||||
<dt><span class="section"><a href="tut/limits/how_to_tell.html">How to
|
||||
|
||||
@@ -77,6 +77,15 @@
|
||||
of <code class="computeroutput"><span class="identifier">number</span></code> on this backend
|
||||
move aware.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
This type is fully <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
aware - basic constexpr arithmetic is supported from C++14 and onwards,
|
||||
comparisons, plus the functions <code class="computeroutput"><span class="identifier">fabs</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">abs</span></code>, <code class="computeroutput"><span class="identifier">fpclassify</span></code>, <code class="computeroutput"><span class="identifier">isnormal</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">isfinite</span></code>, <code class="computeroutput"><span class="identifier">isinf</span></code> and <code class="computeroutput"><span class="identifier">isnan</span></code>
|
||||
are also supported if either the compiler implements C++20's <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_constant_evaluated</span><span class="special">()</span></code>,
|
||||
or if the compiler is GCC.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
It is not possible to round-trip objects of this type to and from a
|
||||
string and get back exactly the same value when compiled with Intel's
|
||||
@@ -97,6 +106,14 @@
|
||||
Type <code class="computeroutput"><span class="identifier">float128</span></code> can be
|
||||
used as a literal type (constexpr support).
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Type <code class="computeroutput"><span class="identifier">float128</span></code> can be
|
||||
used for full <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
arithmetic from C++14 and later with GCC. The functions <code class="computeroutput"><span class="identifier">abs</span></code>, <code class="computeroutput"><span class="identifier">fabs</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">fpclassify</span></code>, <code class="computeroutput"><span class="identifier">isnan</span></code>, <code class="computeroutput"><span class="identifier">isinf</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">isfinite</span></code> and <code class="computeroutput"><span class="identifier">isnormal</span></code> are also <code class="computeroutput"><span class="keyword">constexpr</span></code>,
|
||||
but the transcendental functions are not.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
When using the Intel compiler, the underlying type defaults to <code class="computeroutput"><a class="link" href="float128.html" title="float128">float128</a></code>
|
||||
if it's available and <code class="computeroutput"><span class="identifier">_Quad</span></code>
|
||||
|
||||
@@ -191,7 +191,7 @@ Relative error: 7.55843e-1501
|
||||
<span class="keyword">while</span> <span class="special">(</span><span class="identifier">current_digits</span> <span class="special"><</span> <span class="identifier">digits10</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">current_digits</span> <span class="special">*=</span> <span class="number">2</span><span class="special">;</span>
|
||||
<span class="identifier">scoped_precision</span> <span class="identifier">sp</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">min</span><span class="special">(</span><span class="identifier">current_digits</span><span class="special">,</span> <span class="identifier">digits10</span><span class="special">));</span>
|
||||
<span class="identifier">scoped_precision</span> <span class="identifier">sp</span><span class="special">((</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">min</span><span class="special">)(</span><span class="identifier">current_digits</span><span class="special">,</span> <span class="identifier">digits10</span><span class="special">));</span>
|
||||
<span class="identifier">mpfr_float</span> <span class="identifier">a</span><span class="special">(</span><span class="identifier">a_</span><span class="special">,</span> <span class="identifier">mpfr_float</span><span class="special">::</span><span class="identifier">default_precision</span><span class="special">()),</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">b_</span><span class="special">,</span> <span class="identifier">mpfr_float</span><span class="special">::</span><span class="identifier">default_precision</span><span class="special">());</span>
|
||||
<span class="identifier">guess</span><span class="special">.</span><span class="identifier">precision</span><span class="special">(</span><span class="identifier">mpfr_float</span><span class="special">::</span><span class="identifier">default_precision</span><span class="special">());</span>
|
||||
<span class="identifier">f</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">detail</span><span class="special">::</span><span class="identifier">ibeta_imp</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">guess</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">policies</span><span class="special">::</span><span class="identifier">policy</span><span class="special"><>(),</span> <span class="keyword">false</span><span class="special">,</span> <span class="keyword">true</span><span class="special">,</span> <span class="special">&</span><span class="identifier">f1</span><span class="special">)</span> <span class="special">-</span> <span class="number">0.5f</span><span class="special">;</span>
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
integer operations</a> are overloaded for the built in integer types in
|
||||
<code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">integer</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
Where these operations require a temporary increase in precision (such as
|
||||
for powm), then if no built in type is available, a <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
for <code class="computeroutput"><span class="identifier">powm</span></code>), then if no built
|
||||
in type is available, a <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
of appropriate precision will be used.
|
||||
</p>
|
||||
<p>
|
||||
@@ -161,7 +162,7 @@
|
||||
<p>
|
||||
The regular Miller-Rabin functions in <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">miller_rabin</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
are defined in terms of the above generic operations, and so function equally
|
||||
well for built in and multiprecision types.
|
||||
well for built-in or __fundamental_types and multiprecision types.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
|
||||
@@ -25,11 +25,12 @@
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_multiprecision.tut.import_export"></a><a class="link" href="import_export.html" title="Importing and Exporting Data to and from cpp_int and cpp_bin_float">Importing and
|
||||
Exporting Data to and from cpp_int and cpp_bin_float</a>
|
||||
Exporting Data to and from <code class="computeroutput"><span class="identifier">cpp_int</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">cpp_bin_float</span></code></a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
Any integer number type that uses <code class="computeroutput"><span class="identifier">cpp_int_backend</span></code>
|
||||
as it's implementation layer can import or export it's bits via two non-member
|
||||
as it's implementation layer can import or export its bits via two non-member
|
||||
functions:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">unsigned</span> <span class="identifier">MinBits</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">MaxBits</span><span class="special">,</span> <span class="identifier">cpp_integer_type</span> <span class="identifier">SignType</span><span class="special">,</span> <span class="identifier">cpp_int_check_type</span> <span class="identifier">Checked</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Allocator</span><span class="special">,</span>
|
||||
@@ -54,7 +55,7 @@
|
||||
These functions are designed for data-interchange with other storage formats,
|
||||
and since <a class="link" href="floats/cpp_bin_float.html" title="cpp_bin_float">cpp_bin_float</a>
|
||||
uses <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
internally, by extension they can be used for floating point numbers based
|
||||
internally, by extension they can be used for floating-point numbers based
|
||||
on that backend as well (see example below). Parameters and use are as follows:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">unsigned</span> <span class="identifier">MinBits</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">MaxBits</span><span class="special">,</span> <span class="identifier">cpp_integer_type</span> <span class="identifier">SignType</span><span class="special">,</span> <span class="identifier">cpp_int_check_type</span> <span class="identifier">Checked</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Allocator</span><span class="special">,</span>
|
||||
@@ -134,8 +135,9 @@
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
Note that this function is optimized for the case where the data can be
|
||||
memcpy'ed from the source to the integer - in this case both iterators
|
||||
much be pointers, and everything must be little-endian.
|
||||
<code class="computeroutput"><span class="identifier">memcpy</span></code>ed from the source
|
||||
to the integer - in this case both iterators much be pointers, and everything
|
||||
must be little-endian.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<h5>
|
||||
@@ -167,7 +169,7 @@
|
||||
<span class="comment">// import back again, and check for equality:</span>
|
||||
<span class="identifier">cpp_int</span> <span class="identifier">j</span><span class="special">;</span>
|
||||
<span class="identifier">import_bits</span><span class="special">(</span><span class="identifier">j</span><span class="special">,</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">i</span> <span class="special">==</span> <span class="identifier">j</span><span class="special">);</span>
|
||||
<span class="identifier">BOOST_ASSERT</span><span class="special">(</span><span class="identifier">i</span> <span class="special">==</span> <span class="identifier">j</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
@@ -199,7 +201,7 @@
|
||||
<span class="identifier">import_bits</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">v</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
|
||||
<span class="identifier">cpp_bin_float_100</span> <span class="identifier">g</span><span class="special">(</span><span class="identifier">i</span><span class="special">);</span>
|
||||
<span class="identifier">g</span><span class="special">.</span><span class="identifier">backend</span><span class="special">().</span><span class="identifier">exponent</span><span class="special">()</span> <span class="special">=</span> <span class="identifier">e</span><span class="special">;</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">f</span> <span class="special">==</span> <span class="identifier">g</span><span class="special">);</span>
|
||||
<span class="identifier">BOOST_ASSERT</span><span class="special">(</span><span class="identifier">f</span> <span class="special">==</span> <span class="identifier">g</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
Type <code class="computeroutput"><span class="identifier">mpfi_float_backend</span></code>
|
||||
can be used at fixed precision by specifying a non-zero <code class="computeroutput"><span class="identifier">Digits10</span></code>
|
||||
template parameter, or at variable precision by setting the template argument
|
||||
to zero. The typedefs mpfi_float_50, mpfi_float_100, mpfi_float_500, mpfi_float_1000
|
||||
provide arithmetic types at 50, 100, 500 and 1000 decimal digits precision
|
||||
respectively. The typedef mpfi_float provides a variable precision type
|
||||
whose precision can be controlled via the <code class="computeroutput"><span class="identifier">number</span></code>s
|
||||
member functions.
|
||||
to zero. The <code class="computeroutput"><span class="keyword">typedef</span></code>s <code class="computeroutput"><span class="identifier">mpfi_float_50</span></code>, <code class="computeroutput"><span class="identifier">mpfi_float_100</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">mpfi_float_500</span></code>, <code class="computeroutput"><span class="identifier">mpfi_float_1000</span></code> provide arithmetic types
|
||||
at 50, 100, 500 and 1000 decimal digits precision respectively. The <code class="computeroutput"><span class="keyword">typedef</span> <span class="identifier">mpfi_float</span></code>
|
||||
provides a variable precision type whose precision can be controlled via
|
||||
the <code class="computeroutput"><span class="identifier">number</span></code>s member functions.
|
||||
</p>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
|
||||
@@ -343,6 +343,25 @@
|
||||
with the value 0xffff. This can be used to generate compile time constants
|
||||
that are too large to fit into any built in number type.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The <a class="link" href="cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
types support constexpr arithmetic, provided it is a fixed precision
|
||||
type with no allocator. It may also be a checked integer: in which
|
||||
case a compiler error will be generated on overflow or undefined behaviour.
|
||||
In addition the free functions <code class="computeroutput"><span class="identifier">abs</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">swap</span></code>, <code class="computeroutput"><span class="identifier">multiply</span></code>, <code class="computeroutput"><span class="identifier">add</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">subtract</span></code>, <code class="computeroutput"><span class="identifier">divide_qr</span></code>, <code class="computeroutput"><span class="identifier">integer_modulus</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">powm</span></code>, <code class="computeroutput"><span class="identifier">lsb</span></code>, <code class="computeroutput"><span class="identifier">msb</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">bit_test</span></code>, <code class="computeroutput"><span class="identifier">bit_set</span></code>, <code class="computeroutput"><span class="identifier">bit_unset</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">bit_flip</span></code>, <code class="computeroutput"><span class="identifier">sqrt</span></code>, <code class="computeroutput"><span class="identifier">gcd</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">lcm</span></code> are all supported.
|
||||
Use of <a class="link" href="cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
in this way requires either a C++2a compiler (one which supports <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_constant_evaluated</span><span class="special">()</span></code>),
|
||||
or GCC-6 or later in C++14 mode. Compilers other than GCC and without
|
||||
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_constant_evaluated</span><span class="special">()</span></code>
|
||||
will support a very limited set of operations: expect to hit roadblocks
|
||||
rather easily.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
You can import/export the raw bits of a <a class="link" href="cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
to and from external storage via the <code class="computeroutput"><span class="identifier">import_bits</span></code>
|
||||
|
||||
@@ -69,14 +69,14 @@
|
||||
from <code class="computeroutput"><span class="identifier">b2</span></code> shouldn't be
|
||||
set unless we increment it first:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">assert</span><span class="special">(!</span><span class="identifier">bit_test</span><span class="special">(</span><span class="identifier">b1</span><span class="special">(</span><span class="number">200</span><span class="special">),</span> <span class="number">200</span><span class="special">));</span> <span class="comment">// OK</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">bit_test</span><span class="special">(++</span><span class="identifier">b1</span><span class="special">(</span><span class="number">200</span><span class="special">),</span> <span class="number">200</span><span class="special">));</span> <span class="comment">// OK</span>
|
||||
<pre class="programlisting"><span class="identifier">BOOST_ASSERT</span><span class="special">(!</span><span class="identifier">bit_test</span><span class="special">(</span><span class="identifier">b1</span><span class="special">(</span><span class="number">200</span><span class="special">),</span> <span class="number">200</span><span class="special">));</span> <span class="comment">// OK</span>
|
||||
<span class="identifier">BOOST_ASSERT</span><span class="special">(</span><span class="identifier">bit_test</span><span class="special">(++</span><span class="identifier">b1</span><span class="special">(</span><span class="number">200</span><span class="special">),</span> <span class="number">200</span><span class="special">));</span> <span class="comment">// OK</span>
|
||||
</pre>
|
||||
<p>
|
||||
And of course if we flip the n'th bit after increment, then we should
|
||||
get back to zero:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">assert</span><span class="special">(!</span><span class="identifier">bit_flip</span><span class="special">(++</span><span class="identifier">b1</span><span class="special">(</span><span class="number">200</span><span class="special">),</span> <span class="number">200</span><span class="special">));</span> <span class="comment">// OK</span>
|
||||
<pre class="programlisting"><span class="identifier">BOOST_ASSERT</span><span class="special">(!</span><span class="identifier">bit_flip</span><span class="special">(++</span><span class="identifier">b1</span><span class="special">(</span><span class="number">200</span><span class="special">),</span> <span class="number">200</span><span class="special">));</span> <span class="comment">// OK</span>
|
||||
</pre>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Print all the factorials that will fit inside a 128-bit integer.</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Begin by building a big table of factorials, once we know just how </span>
|
||||
<span class="comment">// Begin by building a big table of factorials, once we know just how</span>
|
||||
<span class="comment">// large the largest is, we'll be able to "pretty format" the results.</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Calculate the largest number that will fit inside 128 bits, we could</span>
|
||||
<span class="comment">// also have used numeric_limits<int128_t>::max() for this value:</span>
|
||||
<span class="identifier">cpp_int</span> <span class="identifier">limit</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">cpp_int</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="special"><<</span> <span class="number">128</span><span class="special">)</span> <span class="special">-</span> <span class="number">1</span><span class="special">;</span>
|
||||
<span class="comment">// </span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Our table of values:</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">cpp_int</span><span class="special">></span> <span class="identifier">results</span><span class="special">;</span>
|
||||
<span class="comment">//</span>
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="limits/constants.html">std::numeric_limits<>
|
||||
constants</a></span></dt>
|
||||
<dt><span class="section"><a href="limits/functions.html">std::numeric_limits<>
|
||||
functions</a></span></dt>
|
||||
<dt><span class="section"><a href="limits/functions.html"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><></span></code> functions</a></span></dt>
|
||||
<dt><span class="section"><a href="limits/limits32.html">Numeric limits
|
||||
for 32-bit platform</a></span></dt>
|
||||
<dt><span class="section"><a href="limits/how_to_tell.html">How to
|
||||
|
||||
@@ -24,12 +24,11 @@
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="boost_multiprecision.tut.limits.functions"></a><a class="link" href="functions.html" title="std::numeric_limits<> functions">std::numeric_limits<>
|
||||
functions</a>
|
||||
<a name="boost_multiprecision.tut.limits.functions"></a><a class="link" href="functions.html" title="std::numeric_limits<> functions"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><></span></code> functions</a>
|
||||
</h4></div></div></div>
|
||||
<h5>
|
||||
<a name="boost_multiprecision.tut.limits.functions.h0"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.limits.functions.max_function"></a></span><a class="link" href="functions.html#boost_multiprecision.tut.limits.functions.max_function">max function</a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.limits.functions.max_function"></a></span><a class="link" href="functions.html#boost_multiprecision.tut.limits.functions.max_function"><code class="computeroutput"><span class="identifier">max</span></code> function</a>
|
||||
</h5>
|
||||
<p>
|
||||
Function <code class="computeroutput"><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">T</span><span class="special">>::</span><span class="identifier">max</span><span class="special">)()</span></code> returns the largest finite value that
|
||||
@@ -79,19 +78,21 @@
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="boost_multiprecision.tut.limits.functions.h2"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.limits.functions.min_function"></a></span><a class="link" href="functions.html#boost_multiprecision.tut.limits.functions.min_function">min function</a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.limits.functions.min_function"></a></span><a class="link" href="functions.html#boost_multiprecision.tut.limits.functions.min_function"><code class="computeroutput"><span class="identifier">min</span></code> function</a>
|
||||
</h5>
|
||||
<p>
|
||||
Function <code class="computeroutput"><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">T</span><span class="special">>::</span><span class="identifier">min</span><span class="special">)()</span></code> returns the minimum finite value that
|
||||
can be represented by the type T.
|
||||
</p>
|
||||
<p>
|
||||
For built-in types there is usually a corresponding MACRO value TYPE_MIN,
|
||||
For built-in types, there is usually a corresponding MACRO value TYPE_MIN,
|
||||
where TYPE is CHAR, INT, FLOAT etc.
|
||||
</p>
|
||||
<p>
|
||||
Other types, including those provided by a typedef, for example <code class="computeroutput"><span class="identifier">INT64_T_MIN</span></code> for <code class="computeroutput"><span class="identifier">int64_t</span></code>,
|
||||
may provide a macro definition.
|
||||
Other types, including those provided by a <code class="computeroutput"><span class="keyword">typedef</span></code>,
|
||||
for example, <code class="computeroutput"><span class="identifier">INT64_T_MIN</span></code>
|
||||
for <code class="computeroutput"><span class="identifier">int64_t</span></code>, may provide
|
||||
a macro definition.
|
||||
</p>
|
||||
<p>
|
||||
For floating-point types, it is more fully defined as the <span class="emphasis"><em>minimum
|
||||
@@ -268,9 +269,14 @@
|
||||
for Floating-point Comparisons</a>
|
||||
</h6>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">epsilon</span></code> is very useful
|
||||
to compute a tolerance when comparing floating-point values, a much more
|
||||
difficult task than is commonly imagined.
|
||||
<a href="https://en.wikipedia.org/wiki/Machine_epsilon" target="_top">Machine epsilon
|
||||
ε</a> is very useful to compute a tolerance when comparing floating-point
|
||||
values, a much more difficult task than is commonly imagined.
|
||||
</p>
|
||||
<p>
|
||||
The C++ standard specifies <a href="https://en.cppreference.com/w/cpp/types/numeric_limits/epsilon" target="_top"><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">epsilon</span><span class="special">()</span></code></a>
|
||||
and Boost.Multiprecision implements this (where possible) for its program-defined
|
||||
types analogous to the __fundamental floating-point types like <code class="computeroutput"><span class="keyword">double</span></code> <code class="computeroutput"><span class="keyword">float</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
For more information than you probably want (but still need) see <a href="http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html" target="_top">What
|
||||
@@ -288,7 +294,12 @@
|
||||
<p>
|
||||
See Donald. E. Knuth. The art of computer programming (vol II). Copyright
|
||||
1998 Addison-Wesley Longman, Inc., 0-201-89684-2. Addison-Wesley Professional;
|
||||
3rd edition.
|
||||
3rd edition. (The relevant equations are in paragraph 4.2.2, Eq. 36 and
|
||||
37.)
|
||||
</p>
|
||||
<p>
|
||||
See <a href="https://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/testing_tools/extended_comparison/floating_point/floating_points_comparison_theory.html" target="_top">Boost.Math
|
||||
floating_point comparison</a> for more details.
|
||||
</p>
|
||||
<p>
|
||||
See also:
|
||||
@@ -323,7 +334,8 @@
|
||||
<p>
|
||||
used thus:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">BOOST_CHECK_CLOSE_FRACTION</span><span class="special">(</span><span class="identifier">expected</span><span class="special">,</span> <span class="identifier">calculated</span><span class="special">,</span> <span class="identifier">tolerance</span><span class="special">);</span>
|
||||
<pre class="programlisting"><span class="identifier">cd</span> <span class="special">./</span><span class="identifier">test</span>
|
||||
<span class="identifier">BOOST_CHECK_CLOSE_FRACTION</span><span class="special">(</span><span class="identifier">expected</span><span class="special">,</span> <span class="identifier">calculated</span><span class="special">,</span> <span class="identifier">tolerance</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
(There is also a version BOOST_CHECK_CLOSE using tolerance as a <span class="bold"><strong>percentage</strong></span> rather than a fraction; usually the fraction
|
||||
@@ -469,10 +481,10 @@
|
||||
<span class="identifier">ss</span><span class="special">.</span><span class="identifier">imbue</span><span class="special">(</span><span class="identifier">new_locale</span><span class="special">);</span>
|
||||
<span class="identifier">T</span> <span class="identifier">inf</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">T</span><span class="special">>::</span><span class="identifier">infinity</span><span class="special">();</span>
|
||||
<span class="identifier">ss</span> <span class="special"><<</span> <span class="identifier">inf</span><span class="special">;</span> <span class="comment">// Write out.</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">ss</span><span class="special">.</span><span class="identifier">str</span><span class="special">()</span> <span class="special">==</span> <span class="string">"inf"</span><span class="special">);</span>
|
||||
<span class="identifier">BOOST_ASSERT</span><span class="special">(</span><span class="identifier">ss</span><span class="special">.</span><span class="identifier">str</span><span class="special">()</span> <span class="special">==</span> <span class="string">"inf"</span><span class="special">);</span>
|
||||
<span class="identifier">T</span> <span class="identifier">r</span><span class="special">;</span>
|
||||
<span class="identifier">ss</span> <span class="special">>></span> <span class="identifier">r</span><span class="special">;</span> <span class="comment">// Read back in.</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">inf</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">);</span> <span class="comment">// Confirms that the floating-point values really are identical.</span>
|
||||
<span class="identifier">BOOST_ASSERT</span><span class="special">(</span><span class="identifier">inf</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">);</span> <span class="comment">// Confirms that the floating-point values really are identical.</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"infinity output was "</span> <span class="special"><<</span> <span class="identifier">ss</span><span class="special">.</span><span class="identifier">str</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="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"infinity input was "</span> <span class="special"><<</span> <span class="identifier">r</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="special">}</span>
|
||||
@@ -481,7 +493,8 @@
|
||||
<span class="identifier">infinity</span> <span class="identifier">input</span> <span class="identifier">was</span> <span class="identifier">inf</span>
|
||||
</pre>
|
||||
<p>
|
||||
Similarly we can do the same with NaN (except that we cannot use <code class="computeroutput"><span class="identifier">assert</span></code>)
|
||||
Similarly we can do the same with NaN (except that we cannot use <code class="computeroutput"><span class="identifier">assert</span></code> (because any comparisons with
|
||||
NaN always return false).
|
||||
</p>
|
||||
<pre class="programlisting"><span class="special">{</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">locale</span> <span class="identifier">old_locale</span><span class="special">;</span>
|
||||
@@ -492,15 +505,15 @@
|
||||
<span class="identifier">T</span> <span class="identifier">n</span><span class="special">;</span>
|
||||
<span class="identifier">T</span> <span class="identifier">NaN</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">T</span><span class="special">>::</span><span class="identifier">quiet_NaN</span><span class="special">();</span>
|
||||
<span class="identifier">ss</span> <span class="special"><<</span> <span class="identifier">NaN</span><span class="special">;</span> <span class="comment">// Write out.</span>
|
||||
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">ss</span><span class="special">.</span><span class="identifier">str</span><span class="special">()</span> <span class="special">==</span> <span class="string">"nan"</span><span class="special">);</span>
|
||||
<span class="identifier">BOOST_ASSERT</span><span class="special">(</span><span class="identifier">ss</span><span class="special">.</span><span class="identifier">str</span><span class="special">()</span> <span class="special">==</span> <span class="string">"nan"</span><span class="special">);</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"NaN output was "</span> <span class="special"><<</span> <span class="identifier">ss</span><span class="special">.</span><span class="identifier">str</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="identifier">ss</span> <span class="special">>></span> <span class="identifier">n</span><span class="special">;</span> <span class="comment">// Read back in.</span>
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"NaN input was "</span> <span class="special"><<</span> <span class="identifier">n</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="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
NaN output was nan NaN input was nan
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">NaN</span> <span class="identifier">output</span> <span class="identifier">was</span> <span class="identifier">nan</span>
|
||||
<span class="identifier">NaN</span> <span class="identifier">input</span> <span class="identifier">was</span> <span class="identifier">nan</span>
|
||||
</pre>
|
||||
<h6>
|
||||
<a name="boost_multiprecision.tut.limits.functions.h10"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.limits.functions.signaling_nan"></a></span><a class="link" href="functions.html#boost_multiprecision.tut.limits.functions.signaling_nan">Signaling
|
||||
|
||||
@@ -26,49 +26,56 @@
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_multiprecision.tut.lits"></a><a class="link" href="lits.html" title="Literal Types and constexpr Support">Literal Types and <code class="computeroutput"><span class="keyword">constexpr</span></code> Support</a>
|
||||
</h3></div></div></div>
|
||||
<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 features described in this section make heavy use of C++11 language
|
||||
features, currently (as of May 2013) only GCC-4.7 and later, and Clang
|
||||
3.3 and later have the support required to make these features work.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<p>
|
||||
There is limited support for <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
and user-defined literals in the library, currently the <code class="computeroutput"><span class="identifier">number</span></code>
|
||||
front end supports <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
on default construction and all forwarding constructors, but not on any of
|
||||
the non-member operators. So if some type <code class="computeroutput"><span class="identifier">B</span></code>
|
||||
is a literal type, then <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">B</span><span class="special">></span></code>
|
||||
is also a literal type, and you will be able to compile-time-construct such
|
||||
a type from any literal that <code class="computeroutput"><span class="identifier">B</span></code>
|
||||
is compile-time-constructible from. However, you will not be able to perform
|
||||
compile-time arithmetic on such types.
|
||||
There are two kinds of <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
support in this library:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
The more basic version requires only C++11 and allow the construction
|
||||
of some number types as literals.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
The more advanced support permits constexpr arithmetic and requires at
|
||||
least C++14 constexpr support, and for many operations C++2a support
|
||||
</li>
|
||||
</ul></div>
|
||||
<h5>
|
||||
<a name="boost_multiprecision.tut.lits.h0"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.lits.declaring_numeric_literals"></a></span><a class="link" href="lits.html#boost_multiprecision.tut.lits.declaring_numeric_literals">Declaring
|
||||
numeric literals</a>
|
||||
</h5>
|
||||
<p>
|
||||
Currently the only backend type provided by the library that is also a literal
|
||||
type are instantiations of <code class="computeroutput"><span class="identifier">cpp_int_backend</span></code>
|
||||
where the Allocator parameter is type <code class="computeroutput"><span class="keyword">void</span></code>,
|
||||
and the Checked parameter is <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">unchecked</span></code>.
|
||||
There are two backend types which are literals:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
<a class="link" href="floats/float128.html" title="float128">float128</a>
|
||||
(which requires GCC), and
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Instantiations of <code class="computeroutput"><span class="identifier">cpp_int_backend</span></code>
|
||||
where the Allocator parameter is type <code class="computeroutput"><span class="keyword">void</span></code>.
|
||||
In addition, prior to C++14 the Checked parameter must be <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">unchecked</span></code>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">constexpr</span> <span class="identifier">float128</span> <span class="identifier">f</span> <span class="special">=</span> <span class="number">0.1</span><span class="identifier">Q</span> <span class="comment">// OK, float128's are always literals in C++11</span>
|
||||
|
||||
<span class="keyword">constexpr</span> <span class="identifier">int128_t</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="comment">// OK, fixed precision int128_t has no allocator.</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">uint1024_t</span> <span class="identifier">j</span> <span class="special">=</span> <span class="number">0</span><span class="identifier">xFFFFFFFF00000000uLL</span><span class="special">;</span> <span class="comment">// OK, fixed precision uint1024_t has no allocator.</span>
|
||||
|
||||
<span class="keyword">constexpr</span> <span class="identifier">checked_uint128_t</span> <span class="identifier">k</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">;</span> <span class="comment">// Error, checked type is not a literal type as we need runtime error checking.</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">checked_uint128_t</span> <span class="identifier">k</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="comment">// OK from C++14 and later, not supported for C++11.</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">checked_uint128_t</span> <span class="identifier">k</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">;</span> <span class="comment">// Error, as this would normally lead to a runtime failure (exception).</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">cpp_int</span> <span class="identifier">l</span> <span class="special">=</span> <span class="number">2</span><span class="special">;</span> <span class="comment">// Error, type is not a literal as it performs memory management.</span>
|
||||
</pre>
|
||||
<p>
|
||||
There is also limited support for user defined-literals - these are limited
|
||||
to unchecked, fixed precision <code class="computeroutput"><span class="identifier">cpp_int</span></code>'s
|
||||
There is also support for user defined-literals with <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
- these are limited to unchecked, fixed precision <code class="computeroutput"><span class="identifier">cpp_int</span></code>'s
|
||||
which are specified in hexadecimal notation. The suffixes supported are:
|
||||
</p>
|
||||
<div class="informaltable"><table class="table">
|
||||
@@ -166,8 +173,8 @@
|
||||
<span class="comment">// Smaller values can be assigned to larger values:</span>
|
||||
<span class="identifier">int256_t</span> <span class="identifier">c</span> <span class="special">=</span> <span class="number">0x1234</span><span class="identifier">_cppi</span><span class="special">;</span> <span class="comment">// OK</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// However, this does not currently work in constexpr contexts:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">int256_t</span> <span class="identifier">d</span> <span class="special">=</span> <span class="number">0x1</span><span class="identifier">_cppi</span><span class="special">;</span> <span class="comment">// Compiler error</span>
|
||||
<span class="comment">// However, this only works in constexpr contexts from C++14 onwards:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">int256_t</span> <span class="identifier">d</span> <span class="special">=</span> <span class="number">0x1</span><span class="identifier">_cppi</span><span class="special">;</span> <span class="comment">// Compiler error in C++11, requires C++14</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Constants can be padded out with leading zeros to generate wider types:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">uint256_t</span> <span class="identifier">e</span> <span class="special">=</span> <span class="number">0</span><span class="identifier">x0000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFF_cppui</span><span class="special">;</span> <span class="comment">// OK</span>
|
||||
@@ -193,6 +200,209 @@
|
||||
<span class="comment">// Which means this also works:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">int1024_t</span> <span class="identifier">j</span> <span class="special">=</span> <span class="special">-</span><span class="identifier">g</span><span class="special">;</span> <span class="comment">// OK: unary minus operator is constexpr.</span>
|
||||
</pre>
|
||||
<h5>
|
||||
<a name="boost_multiprecision.tut.lits.h1"></a>
|
||||
<span class="phrase"><a name="boost_multiprecision.tut.lits.constexpr_arithmetic"></a></span><a class="link" href="lits.html#boost_multiprecision.tut.lits.constexpr_arithmetic">constexpr
|
||||
arithmetic</a>
|
||||
</h5>
|
||||
<p>
|
||||
The front end of the library is all <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
from C++14 and later. Currently there are only two back end types that are
|
||||
<code class="computeroutput"><span class="keyword">constexpr</span></code> aware: <a class="link" href="floats/float128.html" title="float128">float128</a>
|
||||
and <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>.
|
||||
More backends will follow at a later date.
|
||||
</p>
|
||||
<p>
|
||||
Provided the compiler is GCC, type <a class="link" href="floats/float128.html" title="float128">float128</a>
|
||||
support <code class="computeroutput"><span class="keyword">constexpr</span></code> operations
|
||||
on all arithmetic operations from C++14, comparisons, <code class="computeroutput"><span class="identifier">abs</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">fabs</span></code>, <code class="computeroutput"><span class="identifier">fpclassify</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">isnan</span></code>, <code class="computeroutput"><span class="identifier">isinf</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">isfinite</span></code> and <code class="computeroutput"><span class="identifier">isnormal</span></code> are also fully supported, but
|
||||
the transcendental functions are not.
|
||||
</p>
|
||||
<p>
|
||||
The <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
types support constexpr arithmetic, provided it is a fixed precision type
|
||||
with no allocator. It may also be a checked integer: in which case a compiler
|
||||
error will be generated on overflow or undefined behaviour. In addition the
|
||||
free functions <code class="computeroutput"><span class="identifier">abs</span></code>, <code class="computeroutput"><span class="identifier">swap</span></code>, <code class="computeroutput"><span class="identifier">multiply</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">add</span></code>, <code class="computeroutput"><span class="identifier">subtract</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">divide_qr</span></code>, <code class="computeroutput"><span class="identifier">integer_modulus</span></code>, <code class="computeroutput"><span class="identifier">powm</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">lsb</span></code>, <code class="computeroutput"><span class="identifier">msb</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">bit_test</span></code>, <code class="computeroutput"><span class="identifier">bit_set</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">bit_unset</span></code>, <code class="computeroutput"><span class="identifier">bit_flip</span></code>, <code class="computeroutput"><span class="identifier">sqrt</span></code>,
|
||||
<code class="computeroutput"><span class="identifier">gcd</span></code>, <code class="computeroutput"><span class="identifier">lcm</span></code>
|
||||
are all supported. Use of <a class="link" href="ints/cpp_int.html" title="cpp_int">cpp_int</a>
|
||||
in this way requires either a C++2a compiler (one which supports <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_constant_evaluated</span><span class="special">()</span></code>), or GCC-6 or later in C++14 mode. Compilers
|
||||
other than GCC and without <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_constant_evaluated</span><span class="special">()</span></code> will support a very limited set of operations:
|
||||
expect to hit roadblocks rather easily.
|
||||
</p>
|
||||
<p>
|
||||
For example given:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">inline</span> <span class="keyword">constexpr</span> <span class="identifier">T</span> <span class="identifier">circumference</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">radius</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="number">2</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">constants</span><span class="special">::</span><span class="identifier">pi</span><span class="special"><</span><span class="identifier">T</span><span class="special">>()</span> <span class="special">*</span> <span class="identifier">radius</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">inline</span> <span class="keyword">constexpr</span> <span class="identifier">T</span> <span class="identifier">area</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">radius</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">constants</span><span class="special">::</span><span class="identifier">pi</span><span class="special"><</span><span class="identifier">T</span><span class="special">>()</span> <span class="special">*</span> <span class="identifier">radius</span> <span class="special">*</span> <span class="identifier">radius</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
We can now calculate areas and circumferences using all constexpr arithmetic:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">float128</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">constexpr</span> <span class="identifier">float128</span> <span class="identifier">radius</span> <span class="special">=</span> <span class="number">2.25</span><span class="special">;</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">float128</span> <span class="identifier">c</span> <span class="special">=</span> <span class="identifier">circumference</span><span class="special">(</span><span class="identifier">radius</span><span class="special">);</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">float128</span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">area</span><span class="special">(</span><span class="identifier">radius</span><span class="special">);</span>
|
||||
|
||||
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Circumference = "</span> <span class="special"><<</span> <span class="identifier">c</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="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Area = "</span> <span class="special"><<</span> <span class="identifier">a</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Note that these make use of the numeric constants from the Math library,
|
||||
which also happen to be <code class="computeroutput"><span class="keyword">constexpr</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
For a more interesting example, in <a href="../../../../example/constexpr_float_arithmetic_examples.cpp" target="_top">constexpr_float_arithmetic_examples.cpp</a>
|
||||
we define a simple class for <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
polynomial arithmetic:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">Order</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">const_polynomial</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
Given this, we can use recurrence relations to calculate the coefficients
|
||||
for various orthogonal polynomials - in the example we use the Hermite polynomials,
|
||||
only the constructor does any work - it uses the recurrence relations to
|
||||
calculate the coefficient array:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">Order</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">hermite_polynomial</span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Order</span><span class="special">></span> <span class="identifier">m_data</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">hermite_polynomial</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">m_data</span><span class="special">(</span><span class="identifier">hermite_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Order</span> <span class="special">-</span> <span class="number">1</span><span class="special">>().</span><span class="identifier">data</span><span class="special">()</span> <span class="special">*</span> <span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">1</span><span class="special">>{</span><span class="number">0</span><span class="special">,</span> <span class="number">2</span><span class="special">}</span> <span class="special">-</span> <span class="identifier">hermite_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Order</span> <span class="special">-</span> <span class="number">1</span><span class="special">>().</span><span class="identifier">data</span><span class="special">().</span><span class="identifier">derivative</span><span class="special">())</span>
|
||||
<span class="special">{</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">constexpr</span> <span class="keyword">const</span> <span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Order</span><span class="special">>&</span> <span class="identifier">data</span><span class="special">()</span> <span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">constexpr</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">[](</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">)</span><span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">[</span><span class="identifier">N</span><span class="special">];</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">T</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">U</span> <span class="identifier">val</span><span class="special">)</span><span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">(</span><span class="identifier">val</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
Now we just need to define H<sub>0</sub> and H<sub>1</sub> as termination conditions for the recurrence:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">hermite_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">0</span><span class="special">></span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">0</span><span class="special">></span> <span class="identifier">m_data</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">hermite_polynomial</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">m_data</span><span class="special">{</span><span class="number">1</span><span class="special">}</span> <span class="special">{}</span>
|
||||
<span class="keyword">constexpr</span> <span class="keyword">const</span> <span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">0</span><span class="special">>&</span> <span class="identifier">data</span><span class="special">()</span> <span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">constexpr</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">[](</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">)</span> <span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">[</span><span class="identifier">N</span><span class="special">];</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">T</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">U</span> <span class="identifier">val</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">(</span><span class="identifier">val</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">class</span> <span class="identifier">hermite_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">1</span><span class="special">></span>
|
||||
<span class="special">{</span>
|
||||
<span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">1</span><span class="special">></span> <span class="identifier">m_data</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">public</span><span class="special">:</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">hermite_polynomial</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">m_data</span><span class="special">{</span><span class="number">0</span><span class="special">,</span> <span class="number">2</span><span class="special">}</span> <span class="special">{}</span>
|
||||
<span class="keyword">constexpr</span> <span class="keyword">const</span> <span class="identifier">const_polynomial</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="number">1</span><span class="special">>&</span> <span class="identifier">data</span><span class="special">()</span> <span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">constexpr</span> <span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">[](</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">)</span> <span class="keyword">const</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">[</span><span class="identifier">N</span><span class="special">];</span>
|
||||
<span class="special">}</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">T</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">U</span> <span class="identifier">val</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">m_data</span><span class="special">(</span><span class="identifier">val</span><span class="special">);</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
We can now declare H<sub>9</sub> as a constexpr object, access the coefficients, and
|
||||
evaluate at an abscissa value, all using <code class="computeroutput"><span class="keyword">constexpr</span></code>
|
||||
arithmetic:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">constexpr</span> <span class="identifier">hermite_polynomial</span><span class="special"><</span><span class="identifier">float128</span><span class="special">,</span> <span class="number">9</span><span class="special">></span> <span class="identifier">h9</span><span class="special">;</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Verify that the polynomial's coefficients match the known values:</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">0</span><span class="special">]</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">1</span><span class="special">]</span> <span class="special">==</span> <span class="number">30240</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">2</span><span class="special">]</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">3</span><span class="special">]</span> <span class="special">==</span> <span class="special">-</span><span class="number">80640</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">4</span><span class="special">]</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">5</span><span class="special">]</span> <span class="special">==</span> <span class="number">48384</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">6</span><span class="special">]</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">7</span><span class="special">]</span> <span class="special">==</span> <span class="special">-</span><span class="number">9216</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">8</span><span class="special">]</span> <span class="special">==</span> <span class="number">0</span><span class="special">);</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">[</span><span class="number">9</span><span class="special">]</span> <span class="special">==</span> <span class="number">512</span><span class="special">);</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Define an abscissa value to evaluate at:</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">float128</span> <span class="identifier">abscissa</span><span class="special">(</span><span class="number">0.5</span><span class="special">);</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="comment">// Evaluate H_9(0.5) using all constexpr arithmetic:</span>
|
||||
<span class="comment">//</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">h9</span><span class="special">(</span><span class="identifier">abscissa</span><span class="special">)</span> <span class="special">==</span> <span class="number">6481</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Also since the coefficients to the Hermite polynomials are integers, we can
|
||||
also generate the Hermite coefficients using (fixed precision) cpp_int's:
|
||||
see <a href="../../../../test/constexpr_test_cpp_int_6.cpp" target="_top">constexpr_test_cpp_int_6.cpp</a>.
|
||||
</p>
|
||||
<p>
|
||||
We can also generate factorials (and validate the result) like so:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">constexpr</span> <span class="identifier">T</span> <span class="identifier">factorial</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">a</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">a</span> <span class="special">?</span> <span class="identifier">a</span> <span class="special">*</span> <span class="identifier">factorial</span><span class="special">(</span><span class="identifier">a</span> <span class="special">-</span> <span class="number">1</span><span class="special">)</span> <span class="special">:</span> <span class="number">1</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<pre class="programlisting"><span class="keyword">constexpr</span> <span class="identifier">uint1024_t</span> <span class="identifier">f1</span> <span class="special">=</span> <span class="identifier">factorial</span><span class="special">(</span><span class="identifier">uint1024_t</span><span class="special">(</span><span class="number">31</span><span class="special">));</span>
|
||||
<span class="keyword">static_assert</span><span class="special">(</span><span class="identifier">f1</span> <span class="special">==</span> <span class="number">0</span><span class="identifier">x1956ad0aae33a4560c5cd2c000000_cppi</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
Another example in <a href="../../../../test/constexpr_test_cpp_int_7.cpp" target="_top">constexpr_test_cpp_int_7.cpp</a>
|
||||
generates a fresh multiprecision random number each time the file is compiled.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
|
||||
@@ -107,7 +107,8 @@
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/primetest.html">Primality Testing</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/lits.html">Literal Types and <code class="computeroutput"><span class="keyword">constexpr</span></code> Support</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/import_export.html">Importing and
|
||||
Exporting Data to and from cpp_int and cpp_bin_float</a></span></dt>
|
||||
Exporting Data to and from <code class="computeroutput"><span class="identifier">cpp_int</span></code>
|
||||
and <code class="computeroutput"><span class="identifier">cpp_bin_float</span></code></a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/rounding.html">Rounding Rules for
|
||||
Conversions</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/mixed.html">Mixed Precision Arithmetic</a></span></dt>
|
||||
@@ -118,8 +119,7 @@
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/limits/constants.html">std::numeric_limits<>
|
||||
constants</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/limits/functions.html">std::numeric_limits<>
|
||||
functions</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/limits/functions.html"><code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><></span></code> functions</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/limits/limits32.html">Numeric limits
|
||||
for 32-bit platform</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_multiprecision/tut/limits/how_to_tell.html">How to
|
||||
@@ -177,7 +177,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: August 13, 2019 at 14:01:03 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: September 19, 2019 at 14:40:03 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
||||
@@ -84,9 +84,9 @@
|
||||
[/ Hint you may need to enclose equation in brackets if it contains comma(s) to avoid "error invalid number of arguments"]
|
||||
]
|
||||
|
||||
[def __tick [role aligncenter [role green \u2714]]] [/ u2714 is a HEAVY CHECK MARK tick (2713 check mark)]
|
||||
[def __cross [role aligncenter [role red \u2718]]] [/ u2718 is a heavy cross]
|
||||
[def __star [role aligncenter [role red \u2736]]] [/ 6-point star]
|
||||
[def __tick [role aligncenter [role green \u2714]]] [/ u2714 is a HEAVY CHECK MARK tick (2713 check mark), green]
|
||||
[def __cross [role aligncenter [role red \u2718]]] [/ u2718 is a heavy cross, red]
|
||||
[def __star [role aligncenter [role red \u2736]]] [/ 6-point star red ]
|
||||
|
||||
[/Boost.Multiprecision internals links]
|
||||
[def __cpp_int [link boost_multiprecision.tut.ints.cpp_int cpp_int]]
|
||||
@@ -114,6 +114,7 @@
|
||||
|
||||
[/External links as macro definitions.]
|
||||
[def __expression_template [@https://en.wikipedia.org/wiki/Expression_templates expression template]]
|
||||
[def __expression_templates [@https://en.wikipedia.org/wiki/Expression_templates expression templates]] [/plural version]
|
||||
[def __UDT [@http://eel.is/c++draft/definitions#defns.prog.def.type program-defined type]]
|
||||
[def __fundamental_type [@https://en.cppreference.com/w/cpp/language/types fundamental (built-in) type]]
|
||||
|
||||
@@ -127,8 +128,8 @@ range and precision than C++'s ordinary built-in types.
|
||||
The big number types in Multiprecision can be used with a wide
|
||||
selection of basic mathematical operations, elementary transcendental
|
||||
functions as well as the functions in Boost.Math.
|
||||
The Multiprecision types can also interoperate with the
|
||||
__fundamental types in C++ using clearly defined conversion rules.
|
||||
The Multiprecision types can also interoperate with any
|
||||
__fundamental_type in C++ using clearly defined conversion rules.
|
||||
This allows Boost.Multiprecision to be used for all
|
||||
kinds of mathematical calculations involving integer,
|
||||
rational and floating-point types requiring extended
|
||||
@@ -136,20 +137,20 @@ range and precision.
|
||||
|
||||
Multiprecision consists of a generic interface to the
|
||||
mathematics of large numbers as well as a selection of
|
||||
big number back ends, with support for integer, rational,
|
||||
big number back-ends, with support for integer, rational,
|
||||
floating-point, and complex types. Boost.Multiprecision provides a selection
|
||||
of back ends provided off-the-rack in including
|
||||
of back-ends provided off-the-rack in including
|
||||
interfaces to GMP, MPFR, MPIR, MPC, TomMath as well as
|
||||
its own collection of Boost-licensed, header-only back ends for
|
||||
integers, rationals and floats. In addition, user-defined back ends
|
||||
its own collection of Boost-licensed, header-only back-ends for
|
||||
integers, rationals and floats. In addition, user-defined back-ends
|
||||
can be created and used with the interface of Multiprecision,
|
||||
provided the class implementation adheres to the necessary
|
||||
[link boost_multiprecision.ref.backendconc concepts].
|
||||
|
||||
Depending upon the number type, precision may be arbitrarily large
|
||||
(limited only by available memory), fixed at compile time
|
||||
(for example 50 or 100 decimal digits), or a variable controlled at run-time
|
||||
by member functions. The types are __expression_template -enabled for
|
||||
(for example, 50 or 100 decimal digits), or a variable controlled at run-time
|
||||
by member functions. The types are __expression_templates - enabled for
|
||||
better performance than naive user-defined types.
|
||||
|
||||
The Multiprecision library comes in two distinct parts:
|
||||
@@ -165,36 +166,57 @@ unconstrained license.
|
||||
Which is to say some back-ends rely on 3rd party libraries,
|
||||
but a header-only Boost license version is always available (if somewhat slower).
|
||||
|
||||
Should you just wish to cut to the chase and use a fully Boost-licensed number type, then skip to
|
||||
__cpp_int for multiprecision integers, __cpp_rational for rational types,
|
||||
__cpp_dec_float for multiprecision floating-point types
|
||||
and __cpp_complex for complex types.
|
||||
[h5:getting_started Getting started with Boost.Multiprecision]
|
||||
|
||||
The library is often used via one of the predefined typedefs: for example if you wanted an
|
||||
Should you just wish to 'cut to the chase' just to get bigger integers and/or bigger and more precise reals as simply and portably as possible,
|
||||
close to 'drop-in' replacements for the __fundamental_type analogs,
|
||||
then use a fully Boost-licensed number type, and skip to one of more of :
|
||||
|
||||
* __cpp_int for multiprecision integers,
|
||||
* __cpp_rational for rational types,
|
||||
* __cpp_bin_float and __cpp_dec_float for multiprecision floating-point types,
|
||||
* __cpp_complex for complex types.
|
||||
|
||||
The library is very often used via one of the predefined convenience `typedef`s
|
||||
like `boost::multiprecision::int128_t` or `boost::multiprecision::cpp_bin_float_quad`.
|
||||
|
||||
For example, if you want a signed, 128-bit fixed size integer:
|
||||
|
||||
#include <boost/multiprecision/cpp_int.hpp> // Integer types.
|
||||
|
||||
boost::multiprecision::int128_t my_128_bit_int;
|
||||
|
||||
Alternatively, and more adventurously, if you wanted an
|
||||
[@http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic arbitrary precision]
|
||||
integer type using [gmp] as the underlying implementation then you could use:
|
||||
|
||||
#include <boost/multiprecision/gmp.hpp> // Defines the wrappers around the GMP library's types
|
||||
|
||||
boost::multiprecision::mpz_int myint; // Arbitrary precision integer type.
|
||||
|
||||
Or for a simple, portable 128-bit floating-point close to a drop-in for a __fundamental_type like `double`, usually 64-bit
|
||||
|
||||
Alternatively, you can compose your own multiprecision type, by combining `number` with one of the
|
||||
#include <boost/multiprecision/cpp_bin_float.hpp>
|
||||
|
||||
boost::multiprecision::cpp_bin_float_quad my_quad_real;
|
||||
|
||||
Alternatively, you can compose your own 'custom' multiprecision type, by combining `number` with one of the
|
||||
predefined back-end types. For example, suppose you wanted a 300 decimal digit floating-point type
|
||||
based on the [mpfr] library. In this case, there's no predefined typedef with that level of precision,
|
||||
based on the [mpfr] library. In this case, there's no predefined `typedef` with that level of precision,
|
||||
so instead we compose our own:
|
||||
|
||||
#include <boost/multiprecision/mpfr.hpp> // Defines the Backend type that wraps MPFR
|
||||
#include <boost/multiprecision/mpfr.hpp> // Defines the Backend type that wraps MPFR.
|
||||
|
||||
namespace mp = boost::multiprecision; // Reduce the typing a bit later...
|
||||
|
||||
typedef mp::number<mp::mpfr_float_backend<300> > my_float;
|
||||
|
||||
my_float a, b, c; // These variables have 300 decimal digits precision
|
||||
my_float a, b, c; // These variables have 300 decimal digits precision.
|
||||
|
||||
We can repeat the above example, but with the expression templates disabled (for faster compile times, but slower runtimes)
|
||||
by passing a second template argument to `number`:
|
||||
|
||||
#include <boost/multiprecision/mpfr.hpp> // Defines the Backend type that wraps MPFR
|
||||
#include <boost/multiprecision/mpfr.hpp> // Defines the Backend type that wraps MPFR.
|
||||
|
||||
namespace mp = boost::multiprecision; // Reduce the typing a bit later...
|
||||
|
||||
@@ -277,12 +299,12 @@ Instead the operator looks more like this:
|
||||
template <class Backend>
|
||||
``['unmentionable-type]`` operator * (const number<Backend>& a, const number<Backend>& b);
|
||||
|
||||
Where the "unmentionable" return type is an implementation detail that, rather than containing the result
|
||||
Where the '['unmentionable]' return type is an implementation detail that, rather than containing the result
|
||||
of the multiplication, contains instructions on how to compute the result. In effect it's just a pair
|
||||
of references to the arguments of the function, plus some compile-time information that stores what the operation
|
||||
is.
|
||||
|
||||
The great advantage of this method is the ['elimination of temporaries]: for example the "naive" implementation
|
||||
The great advantage of this method is the ['elimination of temporaries]: for example, the "naive" implementation
|
||||
of `operator*` above, requires one temporary for computing the result, and at least another one to return it. It's true
|
||||
that sometimes this overhead can be reduced by using move-semantics, but it can't be eliminated completely. For example,
|
||||
lets suppose we're evaluating a polynomial via Horner's method, something like this:
|
||||
@@ -301,7 +323,7 @@ temporaries to pretty much zero). Note that if we compile with expression templ
|
||||
on, then actually still have no wasted memory allocations as even though temporaries are created, their contents are moved
|
||||
rather than copied.
|
||||
[footnote The actual number generated will depend on the compiler, how well it optimizes the code, and whether it supports
|
||||
rvalue references. The number of 11 temporaries was generated with Visual C++ 10]
|
||||
rvalue references. The number of 11 temporaries was generated with Visual C++ 2010.]
|
||||
|
||||
[important
|
||||
Expression templates can radically reorder the operations in an expression, for example:
|
||||
@@ -369,20 +391,20 @@ internally by the Boost.Math library.
|
||||
|
||||
unless you're absolutely sure that the lifetimes of `a`, `b` and `c` will outlive that of `my_expression`.
|
||||
|
||||
In fact it is particularly easy to create dangling references by mixing expression templates with the auto
|
||||
In fact, it is particularly easy to create dangling references by mixing expression templates with the `auto`
|
||||
keyword, for example:
|
||||
|
||||
`auto val = cpp_dec_float_50("23.1") * 100;`
|
||||
|
||||
In this situation the integer literal is stored directly in the expression template - so its use is OK here -
|
||||
but the cpp_dec_float_50 temporary is stored by reference and then destructed when the statement completes
|
||||
In this situation, the integer literal is stored directly in the expression template - so its use is OK here -
|
||||
but the `cpp_dec_float_50` temporary is stored by reference and then destructed when the statement completes,
|
||||
leaving a dangling reference.
|
||||
|
||||
[*['If in doubt, do not ever mix expression templates with the auto keyword.]]
|
||||
[*['If in doubt, do not ever mix expression templates with the `auto` keyword.]]
|
||||
]
|
||||
|
||||
And finally... the performance improvements from an expression template library like this are often not as
|
||||
dramatic as the reduction in number of temporaries would suggest. For example if we compare this library with
|
||||
dramatic as the reduction in number of temporaries would suggest. For example, if we compare this library with
|
||||
[mpfr_class] and [mpreal], with all three using the underlying [mpfr] library at 50 decimal digits precision then
|
||||
we see the following typical results for polynomial execution:
|
||||
|
||||
@@ -1151,9 +1173,9 @@ to provide an real-number type that is a drop-in replacement for the native C++
|
||||
much greater precision and implementing interval arithmetic.
|
||||
|
||||
Type `mpfi_float_backend` can be used at fixed precision by specifying a non-zero `Digits10` template parameter, or
|
||||
at variable precision by setting the template argument to zero. The typedefs mpfi_float_50, mpfi_float_100,
|
||||
mpfi_float_500, mpfi_float_1000 provide arithmetic types at 50, 100, 500 and 1000 decimal digits precision
|
||||
respectively. The typedef mpfi_float provides a variable precision type whose precision can be controlled via the
|
||||
at variable precision by setting the template argument to zero. The `typedef`s `mpfi_float_50`, `mpfi_float_100`,
|
||||
`mpfi_float_500`, `mpfi_float_1000` provide arithmetic types at 50, 100, 500 and 1000 decimal digits precision
|
||||
respectively. The `typedef mpfi_float` provides a variable precision type whose precision can be controlled via the
|
||||
`number`s member functions.
|
||||
|
||||
[note This type only provides `numeric_limits` support when the precision is fixed at compile time.]
|
||||
@@ -2173,9 +2195,9 @@ a fresh multiprecision random number each time the file is compiled.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:import_export Importing and Exporting Data to and from cpp_int and cpp_bin_float]
|
||||
[section:import_export Importing and Exporting Data to and from `cpp_int` and `cpp_bin_float`]
|
||||
|
||||
Any integer number type that uses `cpp_int_backend` as it's implementation layer can import or export it's bits via two non-member functions:
|
||||
Any integer number type that uses `cpp_int_backend` as it's implementation layer can import or export its bits via two non-member functions:
|
||||
|
||||
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator,
|
||||
expression_template_option ExpressionTemplates, class OutputIterator>
|
||||
@@ -2196,7 +2218,8 @@ Any integer number type that uses `cpp_int_backend` as it's implementation layer
|
||||
bool msv_first = true);
|
||||
|
||||
These functions are designed for data-interchange with other storage formats, and since __cpp_bin_float uses __cpp_int internally,
|
||||
by extension they can be used for floating point numbers based on that backend as well (see example below). Parameters and use are as follows:
|
||||
by extension they can be used for floating-point numbers based on that backend as well (see example below).
|
||||
Parameters and use are as follows:
|
||||
|
||||
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator,
|
||||
expression_template_option ExpressionTemplates, class OutputIterator>
|
||||
@@ -2216,9 +2239,8 @@ within each `chunk_size` block is always in the machines native format. Further
|
||||
has to be specified manually. It may also result in compiler warnings about the value being narrowed.]
|
||||
|
||||
[tip If you're exporting to non-native byte layout, then use
|
||||
[@http://www.boost.org/doc/libs/release/libs/endian/doc/index.html
|
||||
Boost.Endian] to create a custom OutputIterator that
|
||||
reverses the byte order of each chunk prior to actually storing the result.]
|
||||
[@http://www.boost.org/doc/libs/release/libs/endian/doc/index.html Boost.Endian]
|
||||
to create a custom OutputIterator that reverses the byte order of each chunk prior to actually storing the result.]
|
||||
|
||||
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator,
|
||||
expression_template_option ExpressionTemplates, class ForwardIterator>
|
||||
@@ -2241,7 +2263,7 @@ As with exporting, if the external data is to be in a non-native byte order (wit
|
||||
that presents it in native order (see [@http://www.boost.org/doc/libs/release/libs/endian/doc/index.html Boost.Endian]).
|
||||
|
||||
[note
|
||||
Note that this function is optimized for the case where the data can be memcpy'ed from the source to the integer - in this case both
|
||||
Note that this function is optimized for the case where the data can be `memcpy`ed from the source to the integer - in this case both
|
||||
iterators much be pointers, and everything must be little-endian.]
|
||||
|
||||
[h4 Examples]
|
||||
@@ -2250,7 +2272,7 @@ iterators much be pointers, and everything must be little-endian.]
|
||||
|
||||
[IE2]
|
||||
|
||||
[endsect]
|
||||
[endsect] [/section:import_export Importing and Exporting Data to and from `cpp_int` and `cpp_bin_float`]
|
||||
|
||||
[section:rounding Rounding Rules for Conversions]
|
||||
|
||||
@@ -2275,7 +2297,7 @@ The following table summarises the situation for conversions from native types:
|
||||
[[__tommath_rational][See __tom_int]]
|
||||
]
|
||||
|
||||
[endsect]
|
||||
[endsect] [/section:rounding Rounding Rules for Conversions]
|
||||
|
||||
[section:mixed Mixed Precision Arithmetic]
|
||||
|
||||
@@ -2349,18 +2371,17 @@ than it is to explicitly cast the operands to the result type:
|
||||
|
||||
__mpfr_float_backend, __mpf_float, __cpp_int.
|
||||
|
||||
[endsect]
|
||||
[endsect] [/section:mixed Mixed Precision Arithmetic]
|
||||
|
||||
[section:gen_int Generic Integer Operations]
|
||||
|
||||
All of the [link boost_multiprecision.ref.number.integer_functions non-member integer operations] are overloaded for the
|
||||
built in integer types in
|
||||
`<boost/multiprecision/integer.hpp>`.
|
||||
Where these operations require a temporary increase in precision (such as for powm), then
|
||||
Where these operations require a temporary increase in precision (such as for `powm`), then
|
||||
if no built in type is available, a __cpp_int of appropriate precision will be used.
|
||||
|
||||
Some of these functions are trivial, others use compiler intrinsics (where available) to ensure optimal
|
||||
evaluation.
|
||||
Some of these functions are trivial, others use compiler intrinsics (where available) to ensure optimal evaluation.
|
||||
|
||||
The overloaded functions are:
|
||||
|
||||
@@ -2446,9 +2467,9 @@ Returns the integer square root `s` of x and sets `r` to the remainder ['x - s[s
|
||||
bool miller_rabin_test(const number-or-expression-template-type& n, unsigned trials);
|
||||
|
||||
The regular Miller-Rabin functions in `<boost/multiprecision/miller_rabin.hpp>` are defined in terms of the above
|
||||
generic operations, and so function equally well for built in and multiprecision types.
|
||||
generic operations, and so function equally well for built-in or __fundamental_types and multiprecision types.
|
||||
|
||||
[endsect]
|
||||
[endsect] [/section:gen_int Generic Integer Operations]
|
||||
|
||||
[section:serial Boost.Serialization Support]
|
||||
|
||||
@@ -2463,8 +2484,7 @@ support which requires the underlying backend to be serializable.
|
||||
[section:limits Numeric Limits]
|
||||
|
||||
Boost.Multiprecision tries hard to implement `std::numeric_limits` for all types
|
||||
as far as possible and meaningful because experience with Boost.Math
|
||||
has shown that this aids portability.
|
||||
as far as possible and meaningful because experience with Boost.Math has shown that this aids portability.
|
||||
|
||||
The [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf C++ standard library]
|
||||
defines `std::numeric_limits` in section 18.3.2.
|
||||
@@ -2909,9 +2929,9 @@ resulted in the loss of precision, such implementation detects ['denorm loss].
|
||||
|
||||
[endsect] [/section:constants std::numeric_limits<> Constants]
|
||||
|
||||
[section:functions std::numeric_limits<> functions]
|
||||
[section:functions `std::numeric_limits<>` functions]
|
||||
|
||||
[h4 max function]
|
||||
[h4:max_function `max` function]
|
||||
|
||||
Function `(std::numeric_limits<T>::max)()` returns the largest finite value
|
||||
that can be represented by the type T. If there is no such value (and
|
||||
@@ -2944,16 +2964,16 @@ Since C++11: `std::numeric_limits<T>::lowest()` is
|
||||
|
||||
[digits10_5]
|
||||
|
||||
[h4 min function]
|
||||
[h4:min_function `min` function]
|
||||
|
||||
Function `(std::numeric_limits<T>::min)()` returns the minimum finite value
|
||||
that can be represented by the type T.
|
||||
|
||||
For built-in types there is usually a corresponding MACRO value TYPE_MIN,
|
||||
For built-in types, there is usually a corresponding MACRO value TYPE_MIN,
|
||||
where TYPE is CHAR, INT, FLOAT etc.
|
||||
|
||||
Other types, including those provided by a typedef,
|
||||
for example `INT64_T_MIN` for `int64_t`, may provide a macro definition.
|
||||
Other types, including those provided by a `typedef`,
|
||||
for example, `INT64_T_MIN` for `int64_t`, may provide a macro definition.
|
||||
|
||||
For floating-point types,
|
||||
it is more fully defined as the ['minimum positive normalized value].
|
||||
@@ -2962,7 +2982,6 @@ See `std::numeric_limits<T>::denorm_min()` for the smallest denormalized value,
|
||||
|
||||
std::numeric_limits<T>::has_denorm == std::denorm_present
|
||||
|
||||
|
||||
To cater for situations where no `numeric_limits` specialization is available
|
||||
(for example because the precision of the type varies at runtime),
|
||||
packaged versions of this (and other functions) are provided using
|
||||
@@ -3069,7 +3088,10 @@ for reliably checking if floating-point values are close enough.
|
||||
|
||||
See Donald. E. Knuth. The art of computer programming (vol II).
|
||||
Copyright 1998 Addison-Wesley Longman, Inc., 0-201-89684-2.
|
||||
Addison-Wesley Professional; 3rd edition.
|
||||
Addison-Wesley Professional; 3rd edition. (The relevant equations are in paragraph 4.2.2, Eq. 36 and 37.)
|
||||
|
||||
See [@https://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/testing_tools/extended_comparison/floating_point/floating_points_comparison_theory.html Boost.Math floating_point comparison]
|
||||
for more details.
|
||||
|
||||
See also:
|
||||
|
||||
@@ -3082,7 +3104,8 @@ See also:
|
||||
[tolerance_1]
|
||||
|
||||
used thus:
|
||||
cd ./test
|
||||
|
||||
cd ./test
|
||||
BOOST_CHECK_CLOSE_FRACTION(expected, calculated, tolerance);
|
||||
|
||||
(There is also a version BOOST_CHECK_CLOSE using tolerance as a [*percentage] rather than a fraction;
|
||||
@@ -3247,13 +3270,11 @@ inspect `std::numeric_limits<typename T::value_type>`.
|
||||
|
||||
[endsect] [/section:how_to_tell How to Determine the Kind of a Number From `std::numeric_limits`]
|
||||
|
||||
|
||||
[endsect] [/section:limits Numeric Limits]
|
||||
|
||||
|
||||
[section:input_output Input Output]
|
||||
|
||||
|
||||
[h4 Loopback testing]
|
||||
|
||||
['Loopback] or ['round-tripping] refers to writing out a value as a decimal digit string using `std::iostream`,
|
||||
@@ -6119,7 +6140,7 @@ Open question - what should be the default - int32_t or int64_t? (done 2012/09/
|
||||
[[Why not abstract out addition/multiplication algorithms?]
|
||||
[This was deemed not to be practical: these algorithms are intimately
|
||||
tied to the actual data representation used.]]
|
||||
[[How do I choose between Boost.Multiprecision cpp_bin_50 and cpp_dec_50?]
|
||||
[[How do I choose between Boost.Multiprecision `cpp_bin_50` and `cpp_dec_50`?]
|
||||
[Unless you have a specific reason to choose `cpp_dec_`, then the default choice should be `cpp_bin_`,
|
||||
for example using the convenience `typedefs` like `boost::multiprecision::cpp_bin_50` or `boost::multiprecision::cpp_bin_100`.
|
||||
|
||||
|
||||
@@ -30,9 +30,17 @@ project
|
||||
<include>$(tommath_path)
|
||||
<include>../include
|
||||
<include>../../..
|
||||
<toolset>gcc:<cxxflags>-Wno-missing-braces
|
||||
<toolset>gcc-mingw:<cxxflags>-Wa,-mbig-obj
|
||||
# https://digitalkarabela.com/mingw-w64-how-to-fix-file-too-big-too-many-sections/
|
||||
|
||||
<toolset>gcc:<cxxflags>-Wno-missing-braces
|
||||
|
||||
# Assembler error "File too big" caused by lots of C++ templates, for example, math/floating_point_examples.cpp.
|
||||
# Some projects on some toolsets may require
|
||||
# <toolset>gcc-mingw:<cxxflags>\"-Wa,-mbig-obj\"
|
||||
# See https://digitalkarabela.com/mingw-w64-how-to-fix-file-too-big-too-many-sections/
|
||||
# <toolset>gcc-mingw:<cxxflags>-Wa,-mbig-obj # Some projects may overflow assembler and require equivalent of MSVC /bigobj.
|
||||
# Requires version 2.30 of GNU binutils.
|
||||
# Best applied only to projects that require this, see run math/floating_point_examples.cpp below.
|
||||
|
||||
<toolset>darwin:<cxxflags>-Wno-missing-braces
|
||||
<toolset>acc:<cxxflags>+W2068,2461,2236,4070
|
||||
<toolset>intel:<cxxflags>-Qwd264,239
|
||||
@@ -84,7 +92,8 @@ test-suite examples :
|
||||
|
||||
[ run debug_adaptor_snips.cpp no_eh_eg_support ]
|
||||
[ run float128_snips.cpp quadmath no_eh_eg_support : : : [ check-target-builds ../config//has_float128 : : <build>no ] ]
|
||||
[ run floating_point_examples.cpp no_eh_eg_support ]
|
||||
|
||||
[ run floating_point_examples.cpp no_eh_eg_support : : : <toolset>gcc-mingw:<cxxflags>-Wa,-mbig-obj ] # See note above.
|
||||
[ run gauss_laguerre_quadrature.cpp no_eh_eg_support : : : release [ requires cxx11_lambdas ] ]
|
||||
[ run hypergeometric_luke_algorithms.cpp no_eh_eg_support ../../chrono/build//boost_chrono ../../system/build//boost_system : : : [ requires cxx11_nullptr ] ]
|
||||
[ run integer_examples.cpp no_eh_eg_support ]
|
||||
|
||||
@@ -266,6 +266,7 @@ BOOST_AUTO_TEST_CASE(test_numeric_limits_snips)
|
||||
//[digits10_5
|
||||
-(std::numeric_limits<double>::max)() == std::numeric_limits<double>::lowest();
|
||||
//] [/digits10_5]
|
||||
// warning C4553: '==': result of expression not used; did you intend '='? is spurious.
|
||||
}
|
||||
|
||||
{
|
||||
@@ -396,7 +397,7 @@ so the default expression template parameter has been replaced by `et_off`.]
|
||||
std::cout << "Type " << typeid(cpp_bin_float_quad).name() << " does not have NaNs!" << std::endl;
|
||||
}
|
||||
|
||||
//] [/nan_1]
|
||||
//] [/nan_1]
|
||||
}
|
||||
|
||||
{
|
||||
@@ -434,10 +435,11 @@ Then we can equally well use a multiprecision type cpp_bin_float_quad:
|
||||
}
|
||||
|
||||
/*`
|
||||
``
|
||||
infinity output was inf
|
||||
infinity input was inf
|
||||
|
||||
Similarly we can do the same with NaN (except that we cannot use `assert`)
|
||||
``
|
||||
Similarly we can do the same with NaN (except that we cannot use `assert` (because any comparisons with NaN always return false).
|
||||
*/
|
||||
{
|
||||
std::locale old_locale;
|
||||
@@ -454,11 +456,12 @@ Similarly we can do the same with NaN (except that we cannot use `assert`)
|
||||
std::cout << "NaN input was " << n << std::endl;
|
||||
}
|
||||
/*`
|
||||
``
|
||||
NaN output was nan
|
||||
NaN input was nan
|
||||
|
||||
``
|
||||
*/
|
||||
//] [/facet_1]
|
||||
//] [/facet_1]
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -778,7 +778,7 @@ class numeric_limits<boost::multiprecision::number<boost::multiprecision::backen
|
||||
static BOOST_MP_CXX14_CONSTEXPR number_type signaling_NaN() { return 0; }
|
||||
static BOOST_MP_CXX14_CONSTEXPR number_type denorm_min() { return BOOST_MP_QUAD_DENORM_MIN; }
|
||||
BOOST_STATIC_CONSTEXPR bool is_iec559 = true;
|
||||
BOOST_STATIC_CONSTEXPR bool is_bounded = false;
|
||||
BOOST_STATIC_CONSTEXPR bool is_bounded = true;
|
||||
BOOST_STATIC_CONSTEXPR bool is_modulo = false;
|
||||
BOOST_STATIC_CONSTEXPR bool traps = false;
|
||||
BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
|
||||
|
||||
@@ -59,6 +59,15 @@ project : requirements
|
||||
<toolset>intel-win:<runtime-link>static
|
||||
<toolset>intel-win:<link>static
|
||||
<toolset>clang-win:<link>static
|
||||
|
||||
# Assembler error "File too big" caused by lots of C++ templates, for example, math/floating_point_examples.cpp.
|
||||
# Some projects on some toolsets may require
|
||||
# <toolset>gcc-mingw:<cxxflags>\"-Wa,-mbig-obj\"
|
||||
# See https://digitalkarabela.com/mingw-w64-how-to-fix-file-too-big-too-many-sections/
|
||||
# <toolset>gcc-mingw:<cxxflags>-Wa,-mbig-obj # Some projects may overflow assembler and require equivalent of MSVC /bigobj.
|
||||
# Requires version 2.30 of GNU binutils.
|
||||
# Best applied only to projects that require this, see multiprecision/example run math/floating_point_examples.cpp.
|
||||
|
||||
# Speed up compiles:
|
||||
<toolset>msvc:<debug-symbols>off
|
||||
<toolset>intel:<debug-symbols>off
|
||||
|
||||
Reference in New Issue
Block a user