1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>number</title> 5<link rel="stylesheet" href="../../multiprecision.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../index.html" title="Chapter 1. Boost.Multiprecision"> 8<link rel="up" href="../ref.html" title="Reference"> 9<link rel="prev" href="../ref.html" title="Reference"> 10<link rel="next" href="cpp_int_ref.html" title="cpp_int"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="../ref.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cpp_int_ref.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_multiprecision.ref.number"></a><a class="link" href="number.html" title="number">number</a> 28</h3></div></div></div> 29<h5> 30<a name="boost_multiprecision.ref.number.h0"></a> 31 <span class="phrase"><a name="boost_multiprecision.ref.number.synopsis"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.synopsis">Synopsis</a> 32 </h5> 33<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">multiprecision</span><span class="special">{</span> 34 35<span class="keyword">enum</span> <span class="identifier">expression_template_option</span> <span class="special">{</span> <span class="identifier">et_on</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">et_off</span> <span class="special">=</span> <span class="number">0</span> <span class="special">};</span> 36 37<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">expression_template_default</span> 38<span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">expression_template_option</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">et_on</span><span class="special">;</span> <span class="special">};</span> 39 40<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span> <span class="special">=</span> <span class="identifier">expression_template_default</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>::</span><span class="identifier">value</span><span class="special">></span> 41<span class="keyword">class</span> <span class="identifier">number</span> 42<span class="special">{</span> 43<span class="keyword">public</span><span class="special">:</span> 44 <span class="keyword">typedef</span> <span class="identifier">Backend</span> <span class="identifier">backend_type</span><span class="special">;</span> 45 <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special"><</span><span class="identifier">self_type</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">value_type</span><span class="special">;</span> 46 47 <span class="identifier">number</span><span class="special">();</span> 48 <span class="identifier">number</span><span class="special">(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span> 49 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span> 50 <span class="identifier">number</span><span class="special">&</span> <span class="identifier">assign</span><span class="special">(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span> 51 52 <span class="comment">// Member operators</span> 53 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">+=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 54 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">-=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 55 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">*=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 56 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">/=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 57 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">++();</span> 58 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">--();</span> 59 <span class="identifier">number</span> <span class="keyword">operator</span><span class="special">++(</span><span class="keyword">int</span><span class="special">);</span> 60 <span class="identifier">number</span> <span class="keyword">operator</span><span class="special">--(</span><span class="keyword">int</span><span class="special">);</span> 61 62 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">%=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 63 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">&=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 64 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">|=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 65 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">^=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 66 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special"><<=(</span><span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 67 <span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">>>=(</span><span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 68 69 <span class="comment">// Use in Boolean context:</span> 70 <span class="keyword">operator</span> <span class="emphasis"><em>convertible-to-bool-type</em></span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 71 <span class="comment">// swap:</span> 72 <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">number</span><span class="special">&</span> <span class="identifier">other</span><span class="special">);</span> 73 <span class="comment">// Sign:</span> 74 <span class="keyword">bool</span> <span class="identifier">is_zero</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 75 <span class="keyword">int</span> <span class="identifier">sign</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 76 <span class="comment">// string conversion:</span> 77 <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">str</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 78 <span class="comment">// Generic conversion mechanism</span> 79 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 80 <span class="identifier">T</span> <span class="identifier">convert_to</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 81 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 82 <span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="identifier">T</span> <span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 83 <span class="comment">// precision control:</span> 84 <span class="keyword">static</span> <span class="keyword">unsigned</span> <span class="identifier">default_precision</span><span class="special">();</span> 85 <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">default_precision</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">digits10</span><span class="special">);</span> 86 <span class="keyword">unsigned</span> <span class="identifier">precision</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 87 <span class="keyword">void</span> <span class="identifier">precision</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">digits10</span><span class="special">);</span> 88 <span class="comment">// Comparison:</span> 89 <span class="keyword">int</span> <span class="identifier">compare</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">o</span><span class="special">)</span><span class="keyword">const</span><span class="special">;</span> 90 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">V</span><span class="special">></span> 91 <span class="keyword">typename</span> <span class="identifier">enable_if</span><span class="special"><</span><span class="identifier">is_convertible</span><span class="special"><</span><span class="identifier">V</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> <span class="special">>,</span> <span class="keyword">int</span><span class="special">>::</span><span class="identifier">type</span> 92 <span class="identifier">compare</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">V</span><span class="special">&</span> <span class="identifier">o</span><span class="special">)</span><span class="keyword">const</span><span class="special">;</span> 93 <span class="comment">// real and imaginary parts:</span> 94 <span class="identifier">value_type</span> <span class="identifier">real</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 95 <span class="identifier">value_type</span> <span class="identifier">imag</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 96 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 97 <span class="keyword">void</span> <span class="identifier">real</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">val</span><span class="special">);</span> 98 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 99 <span class="keyword">void</span> <span class="identifier">imag</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">val</span><span class="special">);</span> 100 <span class="comment">// Access to the underlying implementation:</span> 101 <span class="identifier">Backend</span><span class="special">&</span> <span class="identifier">backend</span><span class="special">();</span> 102 <span class="keyword">const</span> <span class="identifier">Backend</span><span class="special">&</span> <span class="identifier">backend</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 103<span class="special">};</span> 104 105<span class="comment">// Non member operators:</span> 106<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">+(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 107<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">-(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 108<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">+(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 109<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">-(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 110<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">*(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 111<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">/(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 112<span class="comment">// Integer only operations:</span> 113<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">%(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 114<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">&(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 115<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">|(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 116<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">^(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 117<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special"><<(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 118<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">>>(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 119<span class="comment">// Comparison operators:</span> 120<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 121<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 122<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 123<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 124<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 125<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">>=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 126 127<span class="comment">// Swap:</span> 128<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 129<span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">b</span><span class="special">);</span> 130 131<span class="comment">// iostream support:</span> 132<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 133<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">os</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">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">);</span> 134<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>unmentionable-expression-template-type</em></span><span class="special">&</span> <span class="identifier">r</span><span class="special">);</span> 135<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 136<span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">>></span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span> <span class="identifier">is</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">);</span> 137 138<span class="comment">// Arithmetic with a higher precision result:</span> 139<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">ResultType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Source1</span> <span class="keyword">class</span> <span class="identifier">Source2</span><span class="special">></span> 140<span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">result</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source1</span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source2</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 141<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">ResultType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Source1</span> <span class="keyword">class</span> <span class="identifier">Source2</span><span class="special">></span> 142<span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">subtract</span><span class="special">(</span><span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">result</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source1</span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source2</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 143<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">ResultType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Source1</span> <span class="keyword">class</span> <span class="identifier">Source2</span><span class="special">></span> 144<span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">multiply</span><span class="special">(</span><span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">result</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source1</span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source2</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 145 146<span class="comment">// min and max overloads:</span> 147<span class="emphasis"><em>number</em></span> <span class="identifier">min</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 148<span class="emphasis"><em>number</em></span> <span class="identifier">max</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 149 150<span class="comment">// C99 Non-member function standard library support:</span> 151<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">abs</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 152<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">acos</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 153<span class="emphasis"><em>number</em></span> <span class="identifier">acosh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 154<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">asin</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 155<span class="emphasis"><em>number</em></span> <span class="identifier">asinh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 156<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">atan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 157<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">atan2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 158<span class="emphasis"><em>number</em></span> <span class="identifier">atanh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 159<span class="emphasis"><em>number</em></span> <span class="identifier">cbrt</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 160<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">ceil</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 161<span class="emphasis"><em>number</em></span> <span class="identifier">copysign</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 162<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">cos</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 163<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">cosh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 164<span class="emphasis"><em>number</em></span> <span class="identifier">erf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 165<span class="emphasis"><em>number</em></span> <span class="identifier">erfc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 166<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">exp</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 167<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">exp2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 168<span class="emphasis"><em>number</em></span> <span class="identifier">expm1</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 169<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fabs</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 170<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fdim</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 171<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">floor</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 172<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fma</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 173<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmin</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 174<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmax</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 175<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmod</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 176<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">frexp</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">*);</span> 177<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">hypot</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 178<span class="emphasis"><em>integer-type</em></span> <span class="identifier">ilogb</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 179<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">ldexp</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">);</span> 180<span class="emphasis"><em>number</em></span> <span class="identifier">lgamma</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 181<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">llrint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 182<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">llround</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 183<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">log</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 184<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">log2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 185<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">log10</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 186<span class="emphasis"><em>number</em></span> <span class="identifier">log1p</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 187<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">logb</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 188<span class="keyword">long</span> <span class="identifier">lrint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 189<span class="keyword">long</span> <span class="identifier">lround</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 190<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">modf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 191<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">nearbyint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 192<span class="emphasis"><em>number</em></span> <span class="identifier">nextafter</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 193<span class="emphasis"><em>number</em></span> <span class="identifier">nexttoward</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 194<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">pow</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 195<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">remainder</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 196<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">remquo</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">*);</span> 197<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">rint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 198<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">round</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 199<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">scalbn</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">);</span> 200<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">scalbln</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">);</span> 201<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sin</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 202<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sinh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 203<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sqrt</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 204<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">tan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 205<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">tanh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 206<span class="emphasis"><em>number</em></span> <span class="identifier">tgamma</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 207<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">trunc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 208 209<span class="keyword">int</span> <span class="identifier">fpclassify</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 210<span class="keyword">bool</span> <span class="identifier">isfinite</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 211<span class="keyword">bool</span> <span class="identifier">isinf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 212<span class="keyword">bool</span> <span class="identifier">isnan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 213<span class="keyword">bool</span> <span class="identifier">isnormal</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 214<span class="keyword">int</span> <span class="identifier">signbit</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 215 216<span class="keyword">bool</span> <span class="identifier">isgreater</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 217<span class="keyword">bool</span> <span class="identifier">isgreaterequal</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 218<span class="keyword">bool</span> <span class="identifier">isless</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 219<span class="keyword">bool</span> <span class="identifier">islessequal</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-typearea</em></span><span class="special">&);</span> 220<span class="keyword">bool</span> <span class="identifier">islessgreater</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 221<span class="keyword">bool</span> <span class="identifier">isunordered</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 222<span class="comment">// Complex number functions:</span> 223<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">real</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 224<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">imag</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 225<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">abs</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 226<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">arg</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 227<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">norm</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 228<span class="emphasis"><em>number</em></span> <span class="identifier">conj</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 229<span class="emphasis"><em>number</em></span> <span class="identifier">proj</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 230<span class="emphasis"><em>number</em></span> <span class="identifier">polar</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 231<span class="comment">// Misc other common C library functions:</span> 232<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">itrunc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 233<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">ltrunc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 234<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">lltrunc</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 235<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">iround</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 236<span class="emphasis"><em>number</em></span> <span class="identifier">changesign</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 237<span class="emphasis"><em>number</em></span> <span class="identifier">copysign</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 238 239<span class="comment">// Traits support:</span> 240<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 241<span class="keyword">struct</span> <span class="identifier">component_type</span><span class="special">;</span> 242<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 243<span class="keyword">struct</span> <span class="identifier">number_category</span><span class="special">;</span> 244<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 245<span class="keyword">struct</span> <span class="identifier">is_number</span><span class="special">;</span> 246<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 247<span class="keyword">struct</span> <span class="identifier">is_number_expression</span><span class="special">;</span> 248 249<span class="comment">// Integer specific functions:</span> 250<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">gcd</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 251<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">lcm</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 252<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">pow</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">unsigned</span><span class="special">);</span> 253<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">powm</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">b</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">m</span><span class="special">);</span> 254<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 255<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 256<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">EXpressionTemplates</span><span class="special">></span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">EXpressionTemplates</span><span class="special">>&);</span> 257<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 258<span class="keyword">void</span> <span class="identifier">divide_qr</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">y</span><span class="special">,</span> 259 <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">q</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">);</span> 260<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Integer</span><span class="special">></span> 261<span class="identifier">Integer</span> <span class="identifier">integer_modulus</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">Integer</span> <span class="identifier">val</span><span class="special">);</span> 262<span class="keyword">unsigned</span> <span class="identifier">lsb</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> 263<span class="keyword">unsigned</span> <span class="identifier">msb</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> 264<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 265<span class="keyword">bool</span> <span class="identifier">bit_test</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">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 266<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 267<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">bit_set</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 268<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 269<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">bit_unset</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 270<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 271<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">bit_flip</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 272<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Engine</span><span class="special">></span> 273<span class="keyword">bool</span> <span class="identifier">miller_rabin_test</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">trials</span><span class="special">,</span> <span class="identifier">Engine</span><span class="special">&</span> <span class="identifier">gen</span><span class="special">);</span> 274<span class="keyword">bool</span> <span class="identifier">miller_rabin_test</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">trials</span><span class="special">);</span> 275 276<span class="comment">// Rational number support:</span> 277<span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special"><</span><span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">numerator</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 278<span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special"><</span><span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">denominator</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 279 280<span class="special">}}</span> <span class="comment">// namespaces</span> 281 282<span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> 283 284<span class="comment">// Boost.Math interoperability functions:</span> 285<span class="keyword">int</span> <span class="identifier">fpclassify</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 286<span class="keyword">bool</span> <span class="identifier">isfinite</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 287<span class="keyword">bool</span> <span class="identifier">isnan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 288<span class="keyword">bool</span> <span class="identifier">isinf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 289<span class="keyword">bool</span> <span class="identifier">isnormal</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 290 291<span class="special">}}</span> <span class="comment">// namespaces</span> 292 293<span class="comment">// numeric_limits support:</span> 294<span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">{</span> 295 296<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 297<span class="keyword">struct</span> <span class="identifier">numeric_limits</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">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> <span class="special">></span> 298<span class="special">{</span> 299 <span class="comment">/* Usual members here */</span> 300<span class="special">};</span> 301 302<span class="special">}</span> 303</pre> 304<h5> 305<a name="boost_multiprecision.ref.number.h1"></a> 306 <span class="phrase"><a name="boost_multiprecision.ref.number.description"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.description">Description</a> 307 </h5> 308<pre class="programlisting"><span class="keyword">enum</span> <span class="identifier">expression_template_option</span> <span class="special">{</span> <span class="identifier">et_on</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">et_off</span> <span class="special">=</span> <span class="number">0</span> <span class="special">};</span> 309</pre> 310<p> 311 This enumerated type is used to specify whether expression templates are 312 turned on (et_on) or turned off (et_off). 313 </p> 314<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">expression_template_default</span> 315<span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">expression_template_option</span> <span class="identifier">value</span> <span class="special">=</span> <span class="identifier">et_on</span><span class="special">;</span> <span class="special">};</span> 316</pre> 317<p> 318 This traits class specifies the default expression template option to be 319 used with a particular Backend type. It defaults to <code class="computeroutput"><span class="identifier">et_on</span></code>. 320 </p> 321<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span> <span class="special">=</span> <span class="identifier">expression_template_default</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>::</span><span class="identifier">value</span><span class="special">></span> 322<span class="keyword">class</span> <span class="identifier">number</span><span class="special">;</span> 323</pre> 324<p> 325 Class <code class="computeroutput"><span class="identifier">number</span></code> has two template 326 arguments: 327 </p> 328<div class="variablelist"> 329<p class="title"><b></b></p> 330<dl class="variablelist"> 331<dt><span class="term">Backend</span></dt> 332<dd><p> 333 The actual arithmetic back-end that does all the work. 334 </p></dd> 335<dt><span class="term">ExpressionTemplates</span></dt> 336<dd><p> 337 A Boolean value: when <code class="computeroutput"><span class="identifier">et_on</span></code>, 338 then expression templates are enabled, otherwise when set to <code class="computeroutput"><span class="identifier">et_off</span></code> they are disabled. The default 339 for this parameter is computed via the traits class <code class="computeroutput"><span class="identifier">expression_template_default</span></code> 340 whose member <code class="computeroutput"><span class="identifier">value</span></code> 341 defaults to <code class="computeroutput"><span class="identifier">et_on</span></code> unless 342 the traits class is specialized for a particular backend. 343 </p></dd> 344</dl> 345</div> 346<pre class="programlisting"><span class="identifier">number</span><span class="special">();</span> 347<span class="identifier">number</span><span class="special">(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span> 348<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span> 349<span class="identifier">number</span><span class="special">&</span> <span class="identifier">assign</span><span class="special">(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span> 350</pre> 351<p> 352 Type <code class="computeroutput"><span class="identifier">number</span></code> is default constructible, 353 and both copy constructible and assignable from: 354 </p> 355<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 356<li class="listitem"> 357 Itself. 358 </li> 359<li class="listitem"> 360 An expression template which is the result of one of the arithmetic operators. 361 </li> 362<li class="listitem"> 363 Any <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 364 (built-in)</a> arithmetic type, as long as the result would not be 365 lossy (for example float to integer conversion). 366 </li> 367<li class="listitem"> 368 Any type that the Backend is implicitly constructible or assignable from. 369 </li> 370<li class="listitem"> 371 An rvalue reference to another <code class="computeroutput"><span class="identifier">number</span></code>. 372 Move-semantics are used for construction if the backend also supports 373 rvalue reference construction. In the case of assignment, move semantics 374 are always supported when the argument is an rvalue reference irrespective 375 of the backend. 376 </li> 377<li class="listitem"> 378 Any type in the same family, as long as no loss of precision is involved. 379 For example from <code class="computeroutput"><span class="identifier">int128_t</span></code> 380 to <code class="computeroutput"><span class="identifier">int256_t</span></code>, or <code class="computeroutput"><span class="identifier">cpp_dec_float_50</span></code> to <code class="computeroutput"><span class="identifier">cpp_dec_float_100</span></code>. 381 </li> 382</ul></div> 383<p> 384 Type <code class="computeroutput"><span class="identifier">number</span></code> is explicitly 385 constructible from: 386 </p> 387<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 388<li class="listitem"> 389 Any type mentioned above. 390 </li> 391<li class="listitem"> 392 A <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> or any type which is convertible 393 to <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span></code>. 394 </li> 395<li class="listitem"> 396 Any arithmetic type (including those that would result in lossy conversions). 397 </li> 398<li class="listitem"> 399 Any type in the same family, including those that result in loss of precision. 400 </li> 401<li class="listitem"> 402 Any type that the Backend is explicitly constructible from. 403 </li> 404<li class="listitem"> 405 Any pair of types for which a generic interconversion exists: that is 406 from integer to integer, integer to rational, integer to float, rational 407 to rational, rational to float, or float to float. 408 </li> 409</ul></div> 410<p> 411 The assign member function is available for any type for which an explicit 412 converting constructor exists. It is intended to be used where a temporary 413 generated from an explicit assignment would be expensive, for example: 414 </p> 415<pre class="programlisting"><span class="identifier">mpfr_float_50</span> <span class="identifier">f50</span><span class="special">;</span> 416<span class="identifier">mpfr_float_100</span> <span class="identifier">f100</span><span class="special">;</span> 417 418<span class="identifier">f50</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">mpfr_float_50</span><span class="special">>(</span><span class="identifier">f100</span><span class="special">);</span> <span class="comment">// explicit cast create a temporary</span> 419<span class="identifier">f50</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span><span class="identifier">f100</span><span class="special">);</span> <span class="comment">// explicit call to assign create no temporary</span> 420</pre> 421<p> 422 In addition, if the type has multiple components (for example rational or 423 complex number types), then there is a two argument constructor: 424 </p> 425<pre class="programlisting"><span class="identifier">number</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">);</span> 426</pre> 427<p> 428 Where the two args must either be arithmetic types, or types that are convertible 429 to the two components of <code class="computeroutput"><span class="keyword">this</span></code>. 430 </p> 431<p> 432 Finally, when the type has a variable precision, then there are constructors: 433 </p> 434<pre class="programlisting"><span class="identifier">number</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">precision</span><span class="special">);</span> 435<span class="identifier">number</span><span class="special">(</span><span class="identifier">arg1</span><span class="special">,</span> <span class="identifier">arg2</span><span class="special">,</span> <span class="identifier">precision</span><span class="special">);</span> 436</pre> 437<p> 438 Where <code class="computeroutput"><span class="identifier">precision</span></code> is an unsigned 439 value, the 2 arg version is active for scalar types and/or copy-construction 440 with specific precision, and the 3-arg version for complex types. 441 </p> 442<p> 443 Likewise <code class="computeroutput"><span class="identifier">assign</span></code> has a 2-arg 444 overloaded, with the second argument being the precision. 445 </p> 446<pre class="programlisting"><span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">+=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 447<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">-=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 448<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">*=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 449<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">/=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 450<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">++();</span> 451<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">--();</span> 452<span class="identifier">number</span> <span class="keyword">operator</span><span class="special">++(</span><span class="keyword">int</span><span class="special">);</span> 453<span class="identifier">number</span> <span class="keyword">operator</span><span class="special">--(</span><span class="keyword">int</span><span class="special">);</span> 454<span class="comment">// Integer only operations:</span> 455<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">%=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 456<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">&=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 457<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">|=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 458<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">^=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 459<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special"><<=(</span><span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 460<span class="identifier">number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">>>=(</span><span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 461</pre> 462<p> 463 These operators all take their usual arithmetic meanings. 464 </p> 465<p> 466 The arguments to these operators is either: 467 </p> 468<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 469<li class="listitem"> 470 Another <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> 471 <span class="identifier">ExpressionTemplates</span><span class="special">></span></code>. 472 </li> 473<li class="listitem"> 474 An expression template derived from <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">></span></code>. 475 </li> 476<li class="listitem"> 477 Any type implicitly convertible to <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span></code>, including some other instance of 478 class <code class="computeroutput"><span class="identifier">number</span></code>. 479 </li> 480</ul></div> 481<p> 482 For the left and right shift operations, the argument must be a <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 483 (built-in)</a> integer type with a positive value (negative values result 484 in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code> being thrown). 485 </p> 486<pre class="programlisting"><span class="keyword">operator</span> <span class="emphasis"><em>convertible-to-bool-type</em></span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 487</pre> 488<p> 489 Returns an <span class="emphasis"><em>unmentionable-type</em></span> that is usable in Boolean 490 contexts (this allows <code class="computeroutput"><span class="identifier">number</span></code> 491 to be used in any Boolean context - if statements, conditional statements, 492 or as an argument to a logical operator - without type <code class="computeroutput"><span class="identifier">number</span></code> 493 being convertible to type <code class="computeroutput"><span class="keyword">bool</span></code>. 494 </p> 495<p> 496 This operator also enables the use of <code class="computeroutput"><span class="identifier">number</span></code> 497 with any of the following operators: <code class="computeroutput"><span class="special">!</span></code>, 498 <code class="computeroutput"><span class="special">||</span></code>, <code class="computeroutput"><span class="special">&&</span></code> 499 and <code class="computeroutput"><span class="special">?:</span></code>. 500 </p> 501<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">number</span><span class="special">&</span> <span class="identifier">other</span><span class="special">);</span> 502</pre> 503<p> 504 Swaps <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> 505 with <code class="computeroutput"><span class="identifier">other</span></code>. 506 </p> 507<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">is_zero</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 508</pre> 509<p> 510 Returns <code class="computeroutput"><span class="keyword">true</span></code> is <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is zero, 511 otherwise <code class="computeroutput"><span class="keyword">false</span></code>. 512 </p> 513<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">sign</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 514</pre> 515<p> 516 Returns a value less than zero if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> is negative, a value greater than zero 517 if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> 518 is positive, and zero if <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> 519 is zero. 520 </p> 521<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">str</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">precision</span><span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">scientific</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">)</span><span class="keyword">const</span><span class="special">;</span> 522</pre> 523<p> 524 Returns the number formatted as a string, with at least <span class="emphasis"><em>precision</em></span> 525 digits, and in scientific format if <span class="emphasis"><em>scientific</em></span> is true. 526 </p> 527<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> 528<span class="identifier">T</span> <span class="identifier">convert_to</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 529 530<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 531<span class="keyword">explicit</span> <span class="keyword">operator</span> <span class="identifier">T</span> <span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 532</pre> 533<p> 534 Provides a generic conversion mechanism to convert <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> to type <code class="computeroutput"><span class="identifier">T</span></code>. 535 Type <code class="computeroutput"><span class="identifier">T</span></code> may be any arithmetic 536 type. Optionally other types may also be supported by specific <code class="computeroutput"><span class="identifier">Backend</span></code> types. 537 </p> 538<pre class="programlisting"><span class="keyword">static</span> <span class="keyword">unsigned</span> <span class="identifier">default_precision</span><span class="special">();</span> 539<span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">default_precision</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">digits10</span><span class="special">);</span> 540<span class="keyword">unsigned</span> <span class="identifier">precision</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 541<span class="keyword">void</span> <span class="identifier">precision</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">digits10</span><span class="special">);</span> 542</pre> 543<p> 544 These functions are only available if the Backend template parameter supports 545 runtime changes to precision. They get and set the default precision and 546 the precision of <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> 547 respectively. 548 </p> 549<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">compare</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">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">o</span><span class="special">)</span><span class="keyword">const</span><span class="special">;</span> 550<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">V</span><span class="special">></span> 551<span class="keyword">typename</span> <span class="identifier">enable_if</span><span class="special"><</span><span class="identifier">is_convertible</span><span class="special"><</span><span class="identifier">V</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> <span class="special">>,</span> <span class="keyword">int</span><span class="special">>::</span><span class="identifier">type</span> 552 <span class="identifier">compare</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">V</span><span class="special">&</span> <span class="identifier">other</span><span class="special">)</span><span class="keyword">const</span><span class="special">;</span> 553</pre> 554<p> 555 Returns: 556 </p> 557<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 558<li class="listitem"> 559 A value less that 0 for <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special"><</span> <span class="identifier">other</span></code> 560 </li> 561<li class="listitem"> 562 A value greater that 0 for <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> <span class="special">></span> <span class="identifier">other</span></code> 563 </li> 564<li class="listitem"> 565<p class="simpara"> 566 Zero for <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span> 567 <span class="special">==</span> <span class="identifier">other</span></code> 568 </p> 569<pre class="programlisting"><span class="identifier">value_type</span> <span class="identifier">real</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 570<span class="identifier">value_type</span> <span class="identifier">imag</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 571</pre> 572</li> 573</ul></div> 574<p> 575 These return the real and imaginary parts respectively. If the number is 576 not a complex type, then the imaginary part is always zero. 577 </p> 578<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> 579<span class="keyword">void</span> <span class="identifier">real</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">val</span><span class="special">);</span> 580<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 581<span class="keyword">void</span> <span class="identifier">imag</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">val</span><span class="special">);</span> 582</pre> 583<p> 584 These set the real and imaginary parts respectively of the number. If the 585 number is not a complex type, then setting the real part is equivalent to 586 assignment, and attempting to set the imaginary part will result in a compile 587 time error. 588 </p> 589<pre class="programlisting"><span class="identifier">Backend</span><span class="special">&</span> <span class="identifier">backend</span><span class="special">();</span> 590<span class="keyword">const</span> <span class="identifier">Backend</span><span class="special">&</span> <span class="identifier">backend</span><span class="special">()</span><span class="keyword">const</span><span class="special">;</span> 591</pre> 592<p> 593 Returns the underlying back-end instance used by <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>. 594 </p> 595<h5> 596<a name="boost_multiprecision.ref.number.h2"></a> 597 <span class="phrase"><a name="boost_multiprecision.ref.number.non_member_operators"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.non_member_operators">Non-member 598 operators</a> 599 </h5> 600<pre class="programlisting"><span class="comment">// Non member operators:</span> 601<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">+(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 602<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">-(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 603<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">+(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 604<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">-(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 605<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">*(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 606<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">/(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 607<span class="comment">// Integer only operations:</span> 608<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">%(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 609<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">&(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 610<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">|(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 611<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">^(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 612<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special"><<(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 613<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="keyword">operator</span><span class="special">>>(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>integer-type</em></span><span class="special">&);</span> 614<span class="comment">// Comparison operators:</span> 615<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 616<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 617<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 618<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 619<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 620<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">>=(</span><span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>see-below</em></span><span class="special">&);</span> 621</pre> 622<p> 623 These operators all take their usual arithmetic meanings. 624 </p> 625<p> 626 The arguments to these functions must contain at least one of the following: 627 </p> 628<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 629<li class="listitem"> 630 A <code class="computeroutput"><span class="identifier">number</span></code>. 631 </li> 632<li class="listitem"> 633 An expression template type derived from <code class="computeroutput"><span class="identifier">number</span></code>. 634 </li> 635<li class="listitem"> 636 Any type for which <code class="computeroutput"><span class="identifier">number</span></code> 637 has an implicit constructor - for example a <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 638 (built-in)</a> arithmetic type. 639 </li> 640</ul></div> 641<p> 642 The return type of these operators is either: 643 </p> 644<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 645<li class="listitem"> 646 An <span class="emphasis"><em>unmentionable-type</em></span> expression template type when 647 <code class="computeroutput"><span class="identifier">ExpressionTemplates</span></code> is 648 <code class="computeroutput"><span class="keyword">true</span></code>. 649 </li> 650<li class="listitem"> 651 Type <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> 652 <span class="identifier">et_off</span><span class="special">></span></code> 653 when <code class="computeroutput"><span class="identifier">ExpressionTemplates</span></code> 654 is <code class="computeroutput"><span class="keyword">false</span></code>. 655 </li> 656<li class="listitem"> 657 Type <code class="computeroutput"><span class="keyword">bool</span></code> if the operator 658 is a comparison operator. 659 </li> 660</ul></div> 661<p> 662 Finally note that the second argument to the left and right shift operations 663 must be a <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 664 (built-in)</a> integer type, and that the argument must be positive (negative 665 arguments result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code> 666 being thrown). 667 </p> 668<h5> 669<a name="boost_multiprecision.ref.number.h3"></a> 670 <span class="phrase"><a name="boost_multiprecision.ref.number.swap"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.swap">swap</a> 671 </h5> 672<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 673<span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">b</span><span class="special">);</span> 674</pre> 675<p> 676 Swaps <code class="computeroutput"><span class="identifier">a</span></code> and <code class="computeroutput"><span class="identifier">b</span></code>. 677 </p> 678<h5> 679<a name="boost_multiprecision.ref.number.h4"></a> 680 <span class="phrase"><a name="boost_multiprecision.ref.number.iostream_support"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.iostream_support">Iostream 681 Support</a> 682 </h5> 683<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 684<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">os</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">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">);</span> 685<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Unspecified</span><span class="special">...></span> 686<span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span> <span class="identifier">os</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">unmentionable</span><span class="special">-</span><span class="identifier">expression</span><span class="special">-</span><span class="keyword">template</span><span class="special">&</span> <span class="identifier">r</span><span class="special">);</span> 687<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 688<span class="keyword">inline</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span> <span class="keyword">operator</span> <span class="special">>></span> <span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span> <span class="identifier">is</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">)</span> 689</pre> 690<p> 691 These operators provided formatted input-output operations on <code class="computeroutput"><span class="identifier">number</span></code> types, and expression templates 692 derived from them. 693 </p> 694<p> 695 It's down to the back-end type to actually implement string conversion. However, 696 the back-ends provided with this library support all of the iostream formatting 697 flags, field width and precision settings. 698 </p> 699<h5> 700<a name="boost_multiprecision.ref.number.h5"></a> 701 <span class="phrase"><a name="boost_multiprecision.ref.number.arithmetic_with_a_higher_precisi"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.arithmetic_with_a_higher_precisi">Arithmetic 702 with a higher precision result</a> 703 </h5> 704<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">ResultType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Source1</span> <span class="keyword">class</span> <span class="identifier">Source2</span><span class="special">></span> 705<span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">add</span><span class="special">(</span><span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">result</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source1</span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source2</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 706 707<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">ResultType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Source1</span> <span class="keyword">class</span> <span class="identifier">Source2</span><span class="special">></span> 708<span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">subtract</span><span class="special">(</span><span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">result</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source1</span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source2</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 709 710<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">ResultType</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Source1</span> <span class="keyword">class</span> <span class="identifier">Source2</span><span class="special">></span> 711<span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">multiply</span><span class="special">(</span><span class="identifier">ResultType</span><span class="special">&</span> <span class="identifier">result</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source1</span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Source2</span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 712</pre> 713<p> 714 These functions apply the named operator to the arguments <span class="emphasis"><em>a</em></span> 715 and <span class="emphasis"><em>b</em></span> and store the result in <span class="emphasis"><em>result</em></span>, 716 returning <span class="emphasis"><em>result</em></span>. In all cases they behave "as 717 if" arguments <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span> were 718 first promoted to type <code class="computeroutput"><span class="identifier">ResultType</span></code> 719 before applying the operator, though particular backends may well avoid that 720 step by way of an optimization. 721 </p> 722<p> 723 The type <code class="computeroutput"><span class="identifier">ResultType</span></code> must 724 be an instance of class <code class="computeroutput"><span class="identifier">number</span></code>, 725 and the types <code class="computeroutput"><span class="identifier">Source1</span></code> and 726 <code class="computeroutput"><span class="identifier">Source2</span></code> may be either instances 727 of class <code class="computeroutput"><span class="identifier">number</span></code> or native 728 integer types. The latter is an optimization that allows arithmetic to be 729 performed on native integer types producing an extended precision result. 730 </p> 731<h5> 732<a name="boost_multiprecision.ref.number.h6"></a> 733 <span class="phrase"><a name="boost_multiprecision.ref.number.non_member_standard_library_func"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.non_member_standard_library_func">Non-member 734 standard library function support</a> 735 </h5> 736<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">abs</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 737<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">acos</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 738<span class="emphasis"><em>number</em></span> <span class="identifier">acosh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 739<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">asin</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 740<span class="emphasis"><em>number</em></span> <span class="identifier">asinh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 741<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">atan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 742<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">atan2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 743<span class="emphasis"><em>number</em></span> <span class="identifier">atanh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 744<span class="emphasis"><em>number</em></span> <span class="identifier">cbrt</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 745<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">ceil</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 746<span class="emphasis"><em>number</em></span> <span class="identifier">copysign</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 747<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">cos</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 748<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">cosh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 749<span class="emphasis"><em>number</em></span> <span class="identifier">erf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 750<span class="emphasis"><em>number</em></span> <span class="identifier">erfc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 751<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">exp</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 752<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">exp2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 753<span class="emphasis"><em>number</em></span> <span class="identifier">expm1</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 754<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fabs</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 755<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fdim</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 756<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">floor</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 757<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fma</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 758<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmin</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 759<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmax</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 760<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">fmod</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 761<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">frexp</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">*);</span> 762<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">hypot</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 763<span class="emphasis"><em>integer-type</em></span> <span class="identifier">ilogb</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 764<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">ldexp</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">);</span> 765<span class="emphasis"><em>number</em></span> <span class="identifier">lgamma</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 766<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">llrint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 767<span class="keyword">long</span> <span class="keyword">long</span> <span class="identifier">llround</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 768<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">log</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 769<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">log2</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 770<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">log10</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 771<span class="emphasis"><em>number</em></span> <span class="identifier">log1p</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 772<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">logb</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 773<span class="keyword">long</span> <span class="identifier">lrint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 774<span class="keyword">long</span> <span class="identifier">lround</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 775<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">modf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 776<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">nearbyint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 777<span class="emphasis"><em>number</em></span> <span class="identifier">nextafter</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 778<span class="emphasis"><em>number</em></span> <span class="identifier">nexttoward</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 779<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">pow</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 780<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">remainder</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 781<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">remquo</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">*);</span> 782<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">rint</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 783<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">round</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 784<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">scalbn</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">);</span> 785<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">scalbln</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="emphasis"><em>integer-type</em></span><span class="special">);</span> 786<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sin</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 787<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sinh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 788<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sqrt</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 789<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">tan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 790<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">tanh</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 791<span class="emphasis"><em>number</em></span> <span class="identifier">tgamma</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 792<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">trunc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 793 794<span class="keyword">int</span> <span class="identifier">fpclassify</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 795<span class="keyword">bool</span> <span class="identifier">isfinite</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 796<span class="keyword">bool</span> <span class="identifier">isinf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 797<span class="keyword">bool</span> <span class="identifier">isnan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 798<span class="keyword">bool</span> <span class="identifier">isnormal</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 799<span class="keyword">int</span> <span class="identifier">signbit</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 800 801<span class="keyword">bool</span> <span class="identifier">isgreater</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 802<span class="keyword">bool</span> <span class="identifier">isgreaterequal</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 803<span class="keyword">bool</span> <span class="identifier">isless</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 804<span class="keyword">bool</span> <span class="identifier">islessequal</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 805<span class="keyword">bool</span> <span class="identifier">islessgreater</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 806<span class="keyword">bool</span> <span class="identifier">isunordered</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 807</pre> 808<p> 809 These functions all behave exactly as their standard library C++11 counterparts 810 do: their argument is either an instance of <code class="computeroutput"><span class="identifier">number</span></code> 811 or an expression template derived from it; If the argument is of type <code class="computeroutput"><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">et_off</span><span class="special">></span></code> 812 then that is also the return type, otherwise the return type is an expression 813 template unless otherwise stated. 814 </p> 815<p> 816 The integer type arguments to <code class="computeroutput"><span class="identifier">ldexp</span></code>, 817 <code class="computeroutput"><span class="identifier">frexp</span></code>, <code class="computeroutput"><span class="identifier">scalbn</span></code> 818 and <code class="computeroutput"><span class="identifier">ilogb</span></code> may be either type 819 <code class="computeroutput"><span class="keyword">int</span></code>, or the actual type of the 820 exponent of the number type. 821 </p> 822<p> 823 Complex number types support the following functions: 824 </p> 825<pre class="programlisting"><span class="comment">// Complex number functions:</span> 826<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">real</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 827<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">imag</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 828<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">abs</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 829<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">arg</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 830<span class="emphasis"><em>number<...>::value_type</em></span> <span class="identifier">norm</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 831<span class="emphasis"><em>number</em></span> <span class="identifier">conj</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 832<span class="emphasis"><em>number</em></span> <span class="identifier">proj</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 833<span class="emphasis"><em>number</em></span> <span class="identifier">polar</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 834</pre> 835<p> 836 In addition the functions <code class="computeroutput"><span class="identifier">real</span></code>, 837 <code class="computeroutput"><span class="identifier">imag</span></code>, <code class="computeroutput"><span class="identifier">arg</span></code>, 838 <code class="computeroutput"><span class="identifier">norm</span></code>, <code class="computeroutput"><span class="identifier">conj</span></code> 839 and <code class="computeroutput"><span class="identifier">proj</span></code> are overloaded for 840 scalar (ie non-complex) types in the same manner as <code class="computeroutput"><span class="special"><</span><span class="identifier">complex</span><span class="special">></span></code> 841 and treat the argument as a value whose imaginary part is zero. 842 </p> 843<p> 844 There are also some functions implemented for compatibility with the Boost.Math 845 functions of the same name: 846 </p> 847<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">itrunc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 848<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">ltrunc</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 849<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">lltrunc</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 850<span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">iround</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 851<span class="emphasis"><em>number</em></span> <span class="identifier">changesign</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 852<span class="emphasis"><em>number</em></span> <span class="identifier">copysign</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 853</pre> 854<p> 855 All these functions are normally implemented by the Backend type. However, 856 default versions are provided for Backend types that don't have native support 857 for these functions. Please note however, that this default support requires 858 the precision of the type to be a compile time constant - this means for 859 example that the <a href="http://gmplib.org" target="_top">GMP</a> MPF Backend will 860 not work with these functions when that type is used at variable precision. 861 </p> 862<p> 863 Also note that with the exception of <code class="computeroutput"><span class="identifier">abs</span></code> 864 that these functions can only be used with floating-point Backend types (if 865 any other types such as fixed precision or complex types are added to the 866 library later, then these functions may be extended to support those number 867 types). 868 </p> 869<p> 870 The precision of these functions is generally determined by the backend implementation. 871 For example the precision of these functions when used with <a class="link" href="../tut/floats/mpfr_float.html" title="mpfr_float">mpfr_float</a> 872 is determined entirely by <a href="http://www.mpfr.org" target="_top">MPFR</a>. 873 When these functions use our own implementations, the accuracy of the transcendental 874 functions is generally a few epsilon. Note however, that the trigonometrical 875 functions incur the usual accuracy loss when reducing arguments by large 876 multiples of π. Also note that both <a class="link" href="../tut/floats/gmp_float.html" title="gmp_float">gmp_float</a> 877 and <a class="link" href="../tut/floats/cpp_dec_float.html" title="cpp_dec_float">cpp_dec_float</a> 878 have a number of guard digits beyond their stated precision, so the error 879 rates listed for these are in some sense artificially low. 880 </p> 881<p> 882 The following table shows the error rates we observe for these functions 883 with various backend types, functions not listed here are exact (tested on 884 Win32 with VC++10, MPFR-3.0.0, MPIR-2.1.1): 885 </p> 886<div class="informaltable"><table class="table"> 887<colgroup> 888<col> 889<col> 890<col> 891<col> 892</colgroup> 893<thead><tr> 894<th> 895 <p> 896 Function 897 </p> 898 </th> 899<th> 900 <p> 901 mpfr_float_50 902 </p> 903 </th> 904<th> 905 <p> 906 mpf_float_50 907 </p> 908 </th> 909<th> 910 <p> 911 cpp_dec_float_50 912 </p> 913 </th> 914</tr></thead> 915<tbody> 916<tr> 917<td> 918 <p> 919 sqrt 920 </p> 921 </td> 922<td> 923 <p> 924 1eps 925 </p> 926 </td> 927<td> 928 <p> 929 0eps 930 </p> 931 </td> 932<td> 933 <p> 934 0eps 935 </p> 936 </td> 937</tr> 938<tr> 939<td> 940 <p> 941 exp 942 </p> 943 </td> 944<td> 945 <p> 946 1eps 947 </p> 948 </td> 949<td> 950 <p> 951 0eps 952 </p> 953 </td> 954<td> 955 <p> 956 0eps 957 </p> 958 </td> 959</tr> 960<tr> 961<td> 962 <p> 963 log 964 </p> 965 </td> 966<td> 967 <p> 968 1eps 969 </p> 970 </td> 971<td> 972 <p> 973 0eps 974 </p> 975 </td> 976<td> 977 <p> 978 0eps 979 </p> 980 </td> 981</tr> 982<tr> 983<td> 984 <p> 985 log10 986 </p> 987 </td> 988<td> 989 <p> 990 1eps 991 </p> 992 </td> 993<td> 994 <p> 995 0eps 996 </p> 997 </td> 998<td> 999 <p> 1000 0eps 1001 </p> 1002 </td> 1003</tr> 1004<tr> 1005<td> 1006 <p> 1007 cos 1008 </p> 1009 </td> 1010<td> 1011 <p> 1012 700eps 1013 </p> 1014 </td> 1015<td> 1016 <p> 1017 0eps 1018 </p> 1019 </td> 1020<td> 1021 <p> 1022 0eps 1023 </p> 1024 </td> 1025</tr> 1026<tr> 1027<td> 1028 <p> 1029 sin 1030 </p> 1031 </td> 1032<td> 1033 <p> 1034 1eps 1035 </p> 1036 </td> 1037<td> 1038 <p> 1039 0eps 1040 </p> 1041 </td> 1042<td> 1043 <p> 1044 0eps 1045 </p> 1046 </td> 1047</tr> 1048<tr> 1049<td> 1050 <p> 1051 tan 1052 </p> 1053 </td> 1054<td> 1055 <p> 1056 0eps 1057 </p> 1058 </td> 1059<td> 1060 <p> 1061 0eps 1062 </p> 1063 </td> 1064<td> 1065 <p> 1066 0eps 1067 </p> 1068 </td> 1069</tr> 1070<tr> 1071<td> 1072 <p> 1073 acos 1074 </p> 1075 </td> 1076<td> 1077 <p> 1078 0eps 1079 </p> 1080 </td> 1081<td> 1082 <p> 1083 0eps 1084 </p> 1085 </td> 1086<td> 1087 <p> 1088 0eps 1089 </p> 1090 </td> 1091</tr> 1092<tr> 1093<td> 1094 <p> 1095 asin 1096 </p> 1097 </td> 1098<td> 1099 <p> 1100 0eps 1101 </p> 1102 </td> 1103<td> 1104 <p> 1105 0eps 1106 </p> 1107 </td> 1108<td> 1109 <p> 1110 0eps 1111 </p> 1112 </td> 1113</tr> 1114<tr> 1115<td> 1116 <p> 1117 atan 1118 </p> 1119 </td> 1120<td> 1121 <p> 1122 1eps 1123 </p> 1124 </td> 1125<td> 1126 <p> 1127 0eps 1128 </p> 1129 </td> 1130<td> 1131 <p> 1132 0eps 1133 </p> 1134 </td> 1135</tr> 1136<tr> 1137<td> 1138 <p> 1139 cosh 1140 </p> 1141 </td> 1142<td> 1143 <p> 1144 1045eps<a href="#ftn.boost_multiprecision.ref.number.f0" class="footnote" name="boost_multiprecision.ref.number.f0"><sup class="footnote">[1]</sup></a> 1145 </p> 1146 </td> 1147<td> 1148 <p> 1149 0eps 1150 </p> 1151 </td> 1152<td> 1153 <p> 1154 0eps 1155 </p> 1156 </td> 1157</tr> 1158<tr> 1159<td> 1160 <p> 1161 sinh 1162 </p> 1163 </td> 1164<td> 1165 <p> 1166 2eps 1167 </p> 1168 </td> 1169<td> 1170 <p> 1171 0eps 1172 </p> 1173 </td> 1174<td> 1175 <p> 1176 0eps 1177 </p> 1178 </td> 1179</tr> 1180<tr> 1181<td> 1182 <p> 1183 tanh 1184 </p> 1185 </td> 1186<td> 1187 <p> 1188 1eps 1189 </p> 1190 </td> 1191<td> 1192 <p> 1193 0eps 1194 </p> 1195 </td> 1196<td> 1197 <p> 1198 0eps 1199 </p> 1200 </td> 1201</tr> 1202<tr> 1203<td> 1204 <p> 1205 pow 1206 </p> 1207 </td> 1208<td> 1209 <p> 1210 0eps 1211 </p> 1212 </td> 1213<td> 1214 <p> 1215 4eps 1216 </p> 1217 </td> 1218<td> 1219 <p> 1220 3eps 1221 </p> 1222 </td> 1223</tr> 1224<tr> 1225<td> 1226 <p> 1227 atan2 1228 </p> 1229 </td> 1230<td> 1231 <p> 1232 1eps 1233 </p> 1234 </td> 1235<td> 1236 <p> 1237 0eps 1238 </p> 1239 </td> 1240<td> 1241 <p> 1242 0eps 1243 </p> 1244 </td> 1245</tr> 1246</tbody> 1247<tbody class="footnotes"><tr><td colspan="4"><div id="ftn.boost_multiprecision.ref.number.f0" class="footnote"><p><a href="#boost_multiprecision.ref.number.f0" class="para"><sup class="para">[1] </sup></a> 1248 It's likely that the inherent error in the input values to our 1249 test cases are to blame here. 1250 </p></div></td></tr></tbody> 1251</table></div> 1252<h5> 1253<a name="boost_multiprecision.ref.number.h7"></a> 1254 <span class="phrase"><a name="boost_multiprecision.ref.number.traits_class_support"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.traits_class_support">Traits Class 1255 Support</a> 1256 </h5> 1257<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> 1258<span class="keyword">struct</span> <span class="identifier">component_type</span><span class="special">;</span> 1259</pre> 1260<p> 1261 If this is a type with multiple components (for example rational or complex 1262 types), then this trait has a single member <code class="computeroutput"><span class="identifier">type</span></code> 1263 that is the type of those components. 1264 </p> 1265<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> 1266<span class="keyword">struct</span> <span class="identifier">number_category</span><span class="special">;</span> 1267</pre> 1268<p> 1269 A traits class that inherits from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">int_</span><span class="special"><</span><span class="identifier">N</span><span class="special">></span></code> 1270 where <code class="computeroutput"><span class="identifier">N</span></code> is one of the enumerated 1271 values <code class="computeroutput"><span class="identifier">number_kind_integer</span></code>, 1272 <code class="computeroutput"><span class="identifier">number_kind_floating_point</span></code>, 1273 <code class="computeroutput"><span class="identifier">number_kind_rational</span></code>, <code class="computeroutput"><span class="identifier">number_kind_fixed_point</span></code>, or <code class="computeroutput"><span class="identifier">number_kind_unknown</span></code>. This traits class 1274 is specialized for any type that has <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span></code> 1275 support as well as for classes in this library: which means it can be used 1276 for generic code that must work with <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 1277 (built-in)</a> arithmetic types as well as multiprecision ones. 1278 </p> 1279<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> 1280<span class="keyword">struct</span> <span class="identifier">is_number</span><span class="special">;</span> 1281</pre> 1282<p> 1283 A traits class that inherits from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code> 1284 if T is an instance of <code class="computeroutput"><span class="identifier">number</span><span class="special"><></span></code>, otherwise from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>. 1285 </p> 1286<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> 1287<span class="keyword">struct</span> <span class="identifier">is_number_expression</span><span class="special">;</span> 1288</pre> 1289<p> 1290 A traits class that inherits from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code> 1291 if T is an expression template type derived from <code class="computeroutput"><span class="identifier">number</span><span class="special"><></span></code>, otherwise from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>. 1292 </p> 1293<h5> 1294<a name="boost_multiprecision.ref.number.h8"></a> 1295 <span class="phrase"><a name="boost_multiprecision.ref.number.integer_functions"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.integer_functions">Integer 1296 functions</a> 1297 </h5> 1298<p> 1299 In addition to functioning with types from this library, these functions 1300 are also overloaded for <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 1301 (built-in)</a> integer types if you include <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>. 1302 Further, when used with fixed precision types (whether <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 1303 (built-in)</a> integers or multiprecision ones), the functions will promote 1304 to a wider type internally when the algorithm requires it. Versions overloaded 1305 for <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 1306 (built-in)</a> integer types return that integer type rather than an 1307 expression template. 1308 </p> 1309<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">gcd</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 1310</pre> 1311<p> 1312 Returns the largest integer <code class="computeroutput"><span class="identifier">x</span></code> 1313 that divides both <code class="computeroutput"><span class="identifier">a</span></code> and 1314 <code class="computeroutput"><span class="identifier">b</span></code>. 1315 </p> 1316<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">lcm</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">b</span><span class="special">);</span> 1317</pre> 1318<p> 1319 Returns the smallest integer <code class="computeroutput"><span class="identifier">x</span></code> 1320 that is divisible by both <code class="computeroutput"><span class="identifier">a</span></code> 1321 and <code class="computeroutput"><span class="identifier">b</span></code>. 1322 </p> 1323<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">pow</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">b</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">p</span><span class="special">);</span> 1324</pre> 1325<p> 1326 Returns <span class="emphasis"><em>b<sup>p</sup></em></span> as an expression template. Note that this 1327 function should be used with extreme care as the result can grow so large 1328 as to take "effectively forever" to compute, or else simply run 1329 the host machine out of memory. This is the one function in this category 1330 that is not overloaded for <a href="https://en.cppreference.com/w/cpp/language/types" target="_top">fundamental 1331 (built-in)</a> integer types, further, it's probably not a good idea 1332 to use it with fixed precision <code class="computeroutput"><span class="identifier">cpp_int</span></code>'s 1333 either. 1334 </p> 1335<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">powm</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">b</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">p</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">m</span><span class="special">);</span> 1336</pre> 1337<p> 1338 Returns <span class="emphasis"><em>b<sup>p</sup> mod m</em></span> as an expression template. Fixed precision 1339 types are promoted internally to ensure accuracy. 1340 </p> 1341<pre class="programlisting"><span class="emphasis"><em>unmentionable-expression-template-type</em></span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">a</span><span class="special">);</span> 1342</pre> 1343<p> 1344 Returns the largest integer <code class="computeroutput"><span class="identifier">x</span></code> 1345 such that <code class="computeroutput"><span class="identifier">x</span> <span class="special">*</span> 1346 <span class="identifier">x</span> <span class="special"><</span> 1347 <span class="identifier">a</span></code>. 1348 </p> 1349<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1350<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">EXpressionTemplates</span><span class="special">></span> <span class="identifier">sqrt</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">EXpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">);</span> 1351</pre> 1352<p> 1353 Returns the largest integer <code class="computeroutput"><span class="identifier">x</span></code> 1354 such that <code class="computeroutput"><span class="identifier">x</span> <span class="special">*</span> 1355 <span class="identifier">x</span> <span class="special"><</span> 1356 <span class="identifier">a</span></code>, and sets the remainder <code class="computeroutput"><span class="identifier">r</span></code> such that <code class="computeroutput"><span class="identifier">r</span> 1357 <span class="special">=</span> <span class="identifier">a</span> <span class="special">-</span> <span class="identifier">x</span> <span class="special">*</span> 1358 <span class="identifier">x</span></code>. 1359 </p> 1360<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">expression_template_option</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1361<span class="keyword">void</span> <span class="identifier">divide_qr</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">y</span><span class="special">,</span> 1362 <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">q</span><span class="special">,</span> <span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">r</span><span class="special">);</span> 1363</pre> 1364<p> 1365 Divides x by y and returns both the quotient and remainder. After the call 1366 <code class="computeroutput"><span class="identifier">q</span> <span class="special">=</span> 1367 <span class="identifier">x</span> <span class="special">/</span> <span class="identifier">y</span></code> and <code class="computeroutput"><span class="identifier">r</span> 1368 <span class="special">=</span> <span class="identifier">x</span> <span class="special">%</span> <span class="identifier">y</span></code>. 1369 </p> 1370<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Integer</span><span class="special">></span> 1371<span class="identifier">Integer</span> <span class="identifier">integer_modulus</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">Integer</span> <span class="identifier">val</span><span class="special">);</span> 1372</pre> 1373<p> 1374 Returns the absolute value of <code class="computeroutput"><span class="identifier">x</span> 1375 <span class="special">%</span> <span class="identifier">val</span></code>. 1376 </p> 1377<pre class="programlisting"><span class="keyword">unsigned</span> <span class="identifier">lsb</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> 1378</pre> 1379<p> 1380 Returns the (zero-based) index of the least significant bit that is set to 1381 1. 1382 </p> 1383<p> 1384 Throws a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">range_error</span></code> if the argument is <= 0. 1385 </p> 1386<pre class="programlisting"><span class="keyword">unsigned</span> <span class="identifier">msb</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span> 1387</pre> 1388<p> 1389 Returns the (zero-based) index of the most significant bit. 1390 </p> 1391<p> 1392 Throws a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">range_error</span></code> if the argument is <= 0. 1393 </p> 1394<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1395<span class="keyword">bool</span> <span class="identifier">bit_test</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">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 1396</pre> 1397<p> 1398 Returns <code class="computeroutput"><span class="keyword">true</span></code> if the bit at 1399 <span class="emphasis"><em>index</em></span> in <span class="emphasis"><em>val</em></span> is set. 1400 </p> 1401<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1402<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">bit_set</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 1403</pre> 1404<p> 1405 Sets the bit at <span class="emphasis"><em>index</em></span> in <span class="emphasis"><em>val</em></span>, and 1406 returns <span class="emphasis"><em>val</em></span>. 1407 </p> 1408<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1409<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">bit_unset</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 1410</pre> 1411<p> 1412 Unsets the bit at <span class="emphasis"><em>index</em></span> in <span class="emphasis"><em>val</em></span>, 1413 and returns <span class="emphasis"><em>val</em></span>. 1414 </p> 1415<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1416<span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">bit_flip</span><span class="special">(</span><span class="identifier">number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">>&</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">index</span><span class="special">);</span> 1417</pre> 1418<p> 1419 Flips the bit at <span class="emphasis"><em>index</em></span> in <span class="emphasis"><em>val</em></span>, 1420 and returns <span class="emphasis"><em>val</em></span>. 1421 </p> 1422<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Engine</span><span class="special">></span> 1423<span class="keyword">bool</span> <span class="identifier">miller_rabin_test</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">trials</span><span class="special">,</span> <span class="identifier">Engine</span><span class="special">&</span> <span class="identifier">gen</span><span class="special">);</span> 1424<span class="keyword">bool</span> <span class="identifier">miller_rabin_test</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&</span> <span class="identifier">n</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">trials</span><span class="special">);</span> 1425</pre> 1426<p> 1427 Tests to see if the number <span class="emphasis"><em>n</em></span> is probably prime - the 1428 test excludes the vast majority of composite numbers by excluding small prime 1429 factors and performing a single Fermat test. Then performs <span class="emphasis"><em>trials</em></span> 1430 Miller-Rabin tests. Returns <code class="computeroutput"><span class="keyword">false</span></code> 1431 if <span class="emphasis"><em>n</em></span> is definitely composite, or <code class="computeroutput"><span class="keyword">true</span></code> 1432 if <span class="emphasis"><em>n</em></span> is probably prime with the probability of it being 1433 composite less than 0.25^trials. Fixed precision types are promoted internally 1434 to ensure accuracy. 1435 </p> 1436<h5> 1437<a name="boost_multiprecision.ref.number.h9"></a> 1438 <span class="phrase"><a name="boost_multiprecision.ref.number.rational_number_functions"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.rational_number_functions">Rational 1439 Number Functions</a> 1440 </h5> 1441<pre class="programlisting"><span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special"><</span><span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">numerator</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 1442<span class="keyword">typename</span> <span class="identifier">component_type</span><span class="special"><</span><span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">denominator</span><span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&);</span> 1443</pre> 1444<p> 1445 These functions return the numerator and denominator of a rational number 1446 respectively. 1447 </p> 1448<h5> 1449<a name="boost_multiprecision.ref.number.h10"></a> 1450 <span class="phrase"><a name="boost_multiprecision.ref.number.boost_math_interoperability_supp"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.boost_math_interoperability_supp">Boost.Math 1451 Interoperability Support</a> 1452 </h5> 1453<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span> 1454 1455<span class="keyword">int</span> <span class="identifier">fpclassify</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 1456<span class="keyword">bool</span> <span class="identifier">isfinite</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 1457<span class="keyword">bool</span> <span class="identifier">isnan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 1458<span class="keyword">bool</span> <span class="identifier">isinf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 1459<span class="keyword">bool</span> <span class="identifier">isnormal</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span> 1460 1461<span class="special">}}</span> <span class="comment">// namespaces</span> 1462</pre> 1463<p> 1464 These floating-point classification functions behave exactly as their Boost.Math 1465 equivalents. 1466 </p> 1467<p> 1468 Other Boost.Math functions and templates may also be specialized or overloaded 1469 to ensure interoperability. 1470 </p> 1471<h5> 1472<a name="boost_multiprecision.ref.number.h11"></a> 1473 <span class="phrase"><a name="boost_multiprecision.ref.number.std_numeric_limits_support"></a></span><a class="link" href="number.html#boost_multiprecision.ref.number.std_numeric_limits_support">std::numeric_limits 1474 support</a> 1475 </h5> 1476<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">{</span> 1477 1478<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> 1479<span class="keyword">struct</span> <span class="identifier">numeric_limits</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">Backend</span><span class="special">,</span> <span class="identifier">ExpressionTemplates</span><span class="special">></span> <span class="special">></span> 1480<span class="special">{</span> 1481 <span class="comment">/* Usual members here */</span> 1482<span class="special">};</span> 1483 1484<span class="special">}</span> 1485</pre> 1486<p> 1487 Class template <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span></code> is specialized for all instantiations 1488 of <code class="computeroutput"><span class="identifier">number</span></code> whose precision 1489 is known at compile time, plus those types whose precision is unlimited (though 1490 it is much less useful in those cases). It is not specialized for types whose 1491 precision can vary at compile time (such as <code class="computeroutput"><span class="identifier">mpf_float</span></code>). 1492 </p> 1493</div> 1494<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 1495<td align="left"></td> 1496<td align="right"><div class="copyright-footer">Copyright © 2002-2020 John 1497 Maddock and Christopher Kormanyos<p> 1498 Distributed under the Boost Software License, Version 1.0. (See accompanying 1499 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 1500 </p> 1501</div></td> 1502</tr></table> 1503<hr> 1504<div class="spirit-nav"> 1505<a accesskey="p" href="../ref.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="cpp_int_ref.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 1506</div> 1507</body> 1508</html> 1509