|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75746 - in sandbox/big_number: boost/multiprecision libs/multiprecision/doc libs/multiprecision/doc/html libs/multiprecision/doc/html/boost_multiprecision libs/multiprecision/doc/html/boost_multiprecision/ref libs/multiprecision/doc/html/boost_multiprecision/tut libs/multiprecision/test
From: john_at_[hidden]
Date: 2011-11-30 07:09:02
Author: johnmaddock
Date: 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
New Revision: 75746
URL: http://svn.boost.org/trac/boost/changeset/75746
Log:
Document libtommath support, add error checking to tommath bitwise operators.
Text files modified:
sandbox/big_number/boost/multiprecision/tommath.hpp | 24 +++
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html | 64 ++++++----
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/backendconc.html | 86 +++++++++-----
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/mp_number.html | 228 +++++++++++++++++++++++++++++----------
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html | 153 ++++++++++++++++++++++++-
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/rational.html | 18 +-
sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html | 52 ++++----
sandbox/big_number/libs/multiprecision/doc/html/index.html | 4
sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk | 157 ++++++++++++++++++++++++---
sandbox/big_number/libs/multiprecision/test/Jamfile.v2 | 36 +++--
sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp | 26 +++-
11 files changed, 640 insertions(+), 208 deletions(-)
Modified: sandbox/big_number/boost/multiprecision/tommath.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/tommath.hpp (original)
+++ sandbox/big_number/boost/multiprecision/tommath.hpp 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -229,6 +229,10 @@
mp_int m_data;
};
+#define BOOST_MP_TOMMATH_BIT_OP_CHECK(x)\
+ if(SIGN(&x.data()))\
+ BOOST_THROW_EXCEPTION(std::runtime_error("Bitwise operations on libtommath negative valued integers are disabled as they produce unpredictable results"))
+
int get_sign(const tommath_int& val);
inline void add(tommath_int& t, const tommath_int& o)
@@ -285,16 +289,22 @@
inline void bitwise_and(tommath_int& result, const tommath_int& v)
{
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(result);
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_and(&result.data(), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
inline void bitwise_or(tommath_int& result, const tommath_int& v)
{
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(result);
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_or(&result.data(), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
inline void bitwise_xor(tommath_int& result, const tommath_int& v)
{
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(result);
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_xor(&result.data(), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
@@ -330,21 +340,31 @@
inline void bitwise_and(tommath_int& result, const tommath_int& u, const tommath_int& v)
{
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(u);
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_and(const_cast< ::mp_int*>(&u.data()), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
inline void bitwise_or(tommath_int& result, const tommath_int& u, const tommath_int& v)
{
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(u);
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_or(const_cast< ::mp_int*>(&u.data()), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
inline void bitwise_xor(tommath_int& result, const tommath_int& u, const tommath_int& v)
{
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(u);
+ BOOST_MP_TOMMATH_BIT_OP_CHECK(v);
detail::check_tommath_result(mp_xor(const_cast< ::mp_int*>(&u.data()), const_cast< ::mp_int*>(&v.data()), &result.data()));
}
-
+/*
inline void complement(tommath_int& result, const tommath_int& u)
{
+ //
+ // Although this code works, it doesn't really do what the user might expect....
+ // and it's hard to see how it ever could. Disabled for now:
+ //
result = u;
for(int i = 0; i < result.data().used; ++i)
{
@@ -367,7 +387,7 @@
left_shift(mask, shift);
add(result, mask);
}
-
+*/
inline bool is_zero(const tommath_int& val)
{
return mp_iszero(&val.data());
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/intro.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -20,15 +20,22 @@
<a name="boost_multiprecision.intro"></a><a class="link" href="intro.html" title="Introduction">Introduction</a>
</h2></div></div></div>
<p>
- The Multiprecision library comes in two distinct parts: an expression-template-enabled
- front end <code class="computeroutput"><span class="identifier">mp_number</span></code> that handles
- all the operator overloading, expression evaluation optimization, and code
- reduction, and a selection of backends that implement the actual arithmetic
- operations, and need conform only to the reduced interface requirements of
- the front end.
+ The Multiprecision library comes in two distinct parts:
</p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ An expression-template-enabled front end <code class="computeroutput"><span class="identifier">mp_number</span></code>
+ that handles all the operator overloading, expression evaluation optimization,
+ and code reduction.
+ </li>
+<li class="listitem">
+ A selection of backends that implement the actual arithmetic operations,
+ and need conform only to the reduced interface requirements of the front
+ end.
+ </li>
+</ul></div>
<p>
- The library is often used by using one of the predfined typedefs: for example
+ The library is often used by using one of the predefined typedefs: for example
if you wanted an arbitrary precision integer type using GMP as the underlying
implementation then you could use:
</p>
@@ -37,10 +44,11 @@
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">mpz_int</span> <span class="identifier">myint</span><span class="special">;</span> <span class="comment">// Arbitrary precision integer type.</span>
</pre>
<p>
- Alternatively one can compose your own multiprecision type, by combining <code class="computeroutput"><span class="identifier">mp_number</span></code> with one of the predefined backend
- types. For example, suppose you wanted a 300 decimal digit floating point type
- based on the MPFR library, in this case there's no predefined typedef with
- that level of precision, so instead we compose our own:
+ Alternatively, you can compose your own multiprecision type, by combining
+ <code class="computeroutput"><span class="identifier">mp_number</span></code> with one of the predefined
+ backend types. For example, suppose you wanted a 300 decimal digit floating-point
+ type based on the MPFR library. In this case, there's no predefined typedef
+ with that level of precision, so instead we compose our own:
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">mpfr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> <span class="comment">// Defines the Backend type that wraps MPFR</span>
@@ -50,9 +58,9 @@
<span class="identifier">my_float</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">,</span> <span class="identifier">c</span><span class="special">;</span> <span class="comment">// These variables have 300 decimal digits precision</span>
</pre>
-<a name="boost_multiprecision.intro.expression_templates"></a><h5>
-<a name="boost_multiprecision.intro.expression_templates-heading"></a>
- <a class="link" href="intro.html#boost_multiprecision.intro.expression_templates">Expression
+<h5>
+<a name="boost_multiprecision.intro.h0"></a>
+ <span><a name="boost_multiprecision.intro.expression_templates"></a></span><a class="link" href="intro.html#boost_multiprecision.intro.expression_templates">Expression
Templates</a>
</h5>
<p>
@@ -95,15 +103,15 @@
</pre>
<p>
If type <code class="computeroutput"><span class="identifier">T</span></code> is an <code class="computeroutput"><span class="identifier">mp_number</span></code>, then this expression is evaluated
- <span class="emphasis"><em>without creating a single temporary value</em></span>, in contrast
+ <span class="emphasis"><em>without creating a single temporary value</em></span>. In contrast,
if we were using the C++ wrapper that ships with GMP - <code class="computeroutput"><span class="identifier">mpf_class</span></code>
- then this expression would result in no less than 11 temporaries (this is
- true even though mpf_class does use expression templates to reduce the number
- of temporaries somewhat). Had we used an even simpler wrapper around GMP or
- MPFR like <code class="computeroutput"><span class="identifier">mpclass</span></code> things would
- have been even worse and no less that 24 temporaries are created for this simple
- expression (note - we actually measure the number of memory allocations performed
- rather than the number of temporaries directly).
+ true even though <code class="computeroutput"><span class="identifier">mpf_class</span></code>
+ does use expression templates to reduce the number of temporaries somewhat).
+ Had we used an even simpler wrapper around GMP or MPFR like <code class="computeroutput"><span class="identifier">mpclass</span></code>
+ things would have been even worse and no less that 24 temporaries are created
+ for this simple expression (note - we actually measure the number of memory
+ allocations performed rather than the number of temporaries directly).
</p>
<p>
This library also extends expression template support to standard library functions
@@ -138,11 +146,11 @@
their downsides. For one thing, expression template libraries like this one,
tend to be slower to compile than their simpler cousins, they're also harder
to debug (should you actually want to step through our code!), and rely on
- compiler optimizations being turned on to give really good performance. Also
+ compiler optimizations being turned on to give really good performance. Also,
since the return type from expressions involving <code class="computeroutput"><span class="identifier">mp_number</span></code>'s
is an "unmentionable implementation detail", you have to be careful
to cast the result of an expression to the actual number type when passing
- an expression to a template function. For example given:
+ an expression to a template function. For example, given:
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
<span class="keyword">void</span> <span class="identifier">my_proc</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">T</span><span class="special">&);</span>
@@ -160,7 +168,7 @@
</pre>
<p>
Having said that, these situations don't occur that often - or indeed not at
- all for non-template functions. In addition all the functions in the Boost.Math
+ all for non-template functions. In addition, all the functions in the Boost.Math
library will automatically convert expression-template arguments to the underlying
number type without you having to do anything, so:
</p>
@@ -179,12 +187,12 @@
<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">my_expression</span> <span class="special">=</span> <span class="identifier">a</span> <span class="special">+</span> <span class="identifier">b</span> <span class="special">-</span> <span class="identifier">c</span><span class="special">;</span>
</pre>
<p>
- Unless you're absolutely sure that the lifetimes of <code class="computeroutput"><span class="identifier">a</span></code>,
+ unless you're absolutely sure that the lifetimes of <code class="computeroutput"><span class="identifier">a</span></code>,
<code class="computeroutput"><span class="identifier">b</span></code> and <code class="computeroutput"><span class="identifier">c</span></code>
will outlive that of <code class="computeroutput"><span class="identifier">my_expression</span></code>.
</p>
<p>
- And finally.... the performance improvements from an expression template library
+ And finally... the performance improvements from an expression template library
like this are often not as dramatic as the reduction in number of temporaries
would suggest. For example if we compare this library with <code class="computeroutput"><span class="identifier">mpfr_class</span></code>
and <code class="computeroutput"><span class="identifier">mpreal</span></code>, with all three
@@ -272,7 +280,7 @@
</table></div>
</div>
<br class="table-break"><p>
- As you can see the execution time increases a lot more slowly than the number
+ As you can see, the execution time increases a lot more slowly than the number
of memory allocations. There are a number of reasons for this:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
@@ -296,7 +304,7 @@
<p>
We'll conclude this section by providing some more performance comparisons
between these three libraries, again, all are using MPFR to carry out the underlying
- arithmetic, and all are operating at the same precision (50 decimal places):
+ arithmetic, and all are operating at the same precision (50 decimal digits):
</p>
<div class="table">
<a name="boost_multiprecision.intro.evaluation_of_boost_math_s_bessel_function_test_data"></a><p class="title"><b>Table 1.2. Evaluation of Boost.Math's Bessel function test data</b></p>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/backendconc.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/backendconc.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/backendconc.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -21,7 +21,7 @@
<p>
The requirements on the <code class="computeroutput"><span class="identifier">Backend</span></code>
template argument to <code class="computeroutput"><span class="identifier">mp_number</span></code>
- are split up into compulsary requirements, and optional requirements that
+ are split up into compulsory requirements, and optional requirements that
are either to improve performance or provide optional features.
</p>
<p>
@@ -33,13 +33,13 @@
is a variable of type <code class="computeroutput"><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span></code>, <code class="computeroutput"><span class="identifier">ui</span></code> is a variable of type <code class="computeroutput"><span class="keyword">unsigned</span></code>, <code class="computeroutput"><span class="identifier">bb</span></code>
is a variable of type <code class="computeroutput"><span class="keyword">bool</span></code>,
<code class="computeroutput"><span class="identifier">pa</span></code> is a variable of type
- pointer-to-arithmetc-type, <code class="computeroutput"><span class="identifier">exp</span></code>
+ pointer-to-arithmetic-type, <code class="computeroutput"><span class="identifier">exp</span></code>
is a variable of type <code class="computeroutput"><span class="identifier">B</span><span class="special">::</span><span class="identifier">exp_type</span></code>, <code class="computeroutput"><span class="identifier">pexp</span></code>
is a variable of type <code class="computeroutput"><span class="identifier">B</span><span class="special">::</span><span class="identifier">exp_type</span><span class="special">*</span></code>.
</p>
<div class="table">
-<a name="boost_multiprecision.ref.backendconc.compulsary_requirements_on_the_backend_type_"></a><p class="title"><b>Table 1.4. Compulsary Requirements on the Backend type.</b></p>
-<div class="table-contents"><table class="table" summary="Compulsary Requirements on the Backend type.">
+<a name="boost_multiprecision.ref.backendconc.compulsory_requirements_on_the_backend_type_"></a><p class="title"><b>Table 1.4. Compulsory Requirements on the Backend type.</b></p>
+<div class="table-contents"><table class="table" summary="Compulsory Requirements on the Backend type.">
<colgroup>
<col>
<col>
@@ -114,7 +114,7 @@
</td>
<td>
<p>
- A list of floating point types that can be assigned to type B.The
+ A list of floating-point types that can be assigned to type B.The
types shall be listed in order of size, smallest first, and shall
terminate in type <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">double</span></code>.
</p>
@@ -234,7 +234,7 @@
</td>
<td>
<p>
- Swaps the contents of it's arguments.
+ Swaps the contents of its arguments.
</p>
</td>
</tr>
@@ -591,7 +591,7 @@
and <code class="computeroutput"><span class="special">*</span><span class="identifier">pexp</span></code>
such that the value of <code class="computeroutput"><span class="identifier">cb</span></code>
is b * 2<sup>*pexp</sup>, only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is a floating point type.
+ is a floating-point type.
</p>
</td>
</tr>
@@ -612,7 +612,7 @@
<p>
Stores a value in <code class="computeroutput"><span class="identifier">b</span></code>
that is cb * 2<sup>exp</sup>, only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is a floating point type.
+ is a floating-point type.
</p>
</td>
</tr>
@@ -632,8 +632,8 @@
<p>
Stores the floor of <code class="computeroutput"><span class="identifier">cb</span></code>
in <code class="computeroutput"><span class="identifier">b</span></code>, only required
- when <code class="computeroutput"><span class="identifier">B</span></code> is a floating
- point type.
+ when <code class="computeroutput"><span class="identifier">B</span></code> is a floating-point
+ type.
</p>
</td>
</tr>
@@ -653,8 +653,8 @@
<p>
Stores the ceiling of <code class="computeroutput"><span class="identifier">cb</span></code>
in <code class="computeroutput"><span class="identifier">b</span></code>, only required
- when <code class="computeroutput"><span class="identifier">B</span></code> is a floating
- point type.
+ when <code class="computeroutput"><span class="identifier">B</span></code> is a floating-point
+ type.
</p>
</td>
</tr>
@@ -674,8 +674,30 @@
<p>
Stores the square root of <code class="computeroutput"><span class="identifier">cb</span></code>
in <code class="computeroutput"><span class="identifier">b</span></code>, only required
- when <code class="computeroutput"><span class="identifier">B</span></code> is a floating
- point type.
+ when <code class="computeroutput"><span class="identifier">B</span></code> is a floating-point
+ type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">number_category</span><span class="special"><</span><span class="identifier">B</span><span class="special">>::</span><span class="identifier">type</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ <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>
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">N</span></code> is one of the
+ values <code class="computeroutput"><span class="identifier">number_kind_integer</span></code>,
+ <code class="computeroutput"><span class="identifier">number_kind_floating_point</span></code>,
+ <code class="computeroutput"><span class="identifier">number_kind_rational</span></code>
+ or <code class="computeroutput"><span class="identifier">number_kind_fixed_point</span></code>.
+ Defaults to <code class="computeroutput"><span class="identifier">number_kind_floating_point</span></code>.
</p>
</td>
</tr>
@@ -1618,7 +1640,7 @@
<p>
Returns one of the same values returned by <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">fpclassify</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1640,7 +1662,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1663,7 +1685,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1685,7 +1707,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1707,7 +1729,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1729,7 +1751,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1751,7 +1773,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1773,7 +1795,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1795,7 +1817,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1817,7 +1839,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1839,7 +1861,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1861,7 +1883,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1883,7 +1905,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1905,7 +1927,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1927,7 +1949,7 @@
on argument <code class="computeroutput"><span class="identifier">cb</span></code>
and stores the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1951,7 +1973,7 @@
and <code class="computeroutput"><span class="identifier">cb2</span></code>, and store
the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1975,7 +1997,7 @@
and <code class="computeroutput"><span class="identifier">cb2</span></code>, and store
the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
@@ -1999,7 +2021,7 @@
and <code class="computeroutput"><span class="identifier">cb2</span></code>, and store
the result in <code class="computeroutput"><span class="identifier">b</span></code>.
Only required when <code class="computeroutput"><span class="identifier">B</span></code>
- is an floating point type.
+ is an floating-point type.
</p>
</td>
</tr>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/mp_number.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/mp_number.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/ref/mp_number.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -19,9 +19,9 @@
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_multiprecision.ref.mp_number"></a><a class="link" href="mp_number.html" title="mp_number">mp_number</a>
</h3></div></div></div>
-<a name="boost_multiprecision.ref.mp_number.synopsis"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.synopsis-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.synopsis">Synopsis</a>
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h0"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.synopsis"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.synopsis">Synopsis</a>
</h5>
<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>
@@ -32,7 +32,22 @@
<span class="identifier">mp_number</span><span class="special">(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span>
<span class="identifier">mp_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>
- <span class="comment">/* Other number-type operators here */</span>
+ <span class="comment">// Member operators</span>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">++();</span>
+ <span class="identifier">mp_number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">--();</span>
+ <span class="identifier">mp_number</span> <span class="keyword">operator</span><span class="special">++(</span><span class="keyword">int</span><span class="special">);</span>
+ <span class="identifier">mp_number</span> <span class="keyword">operator</span><span class="special">--(</span><span class="keyword">int</span><span class="special">);</span>
+
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
+ <span class="identifier">mp_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>
<span class="comment">// Use in Boolean context:</span>
<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>
@@ -60,6 +75,26 @@
<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>
<span class="special">};</span>
+<span class="comment">// Non member operators:</span>
+<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>
+<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>
+<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>
+<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>
+<span class="comment">// Integer only operations:</span>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<span class="comment">// Comparison operators:</span>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+
<span class="comment">// Swap:</span>
<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">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>&</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>&</span> <span class="identifier">b</span><span class="special">);</span>
@@ -128,9 +163,9 @@
<span class="special">}</span>
</pre>
-<a name="boost_multiprecision.ref.mp_number.description"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.description-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.description">Description</a>
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h1"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.description"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.description">Description</a>
</h5>
<pre class="programlisting"><span class="identifier">mp_number</span><span class="special">();</span>
<span class="identifier">mp_number</span><span class="special">(</span><span class="identifier">see</span><span class="special">-</span><span class="identifier">below</span><span class="special">);</span>
@@ -158,41 +193,43 @@
Any type that the Backend is constructible or assignable from.
</li>
</ul></div>
-<pre class="programlisting"><span class="comment">/* Other number-type operators here */</span>
+<pre class="programlisting"><span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">++();</span>
+<span class="identifier">mp_number</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">--();</span>
+<span class="identifier">mp_number</span> <span class="keyword">operator</span><span class="special">++(</span><span class="keyword">int</span><span class="special">);</span>
+<span class="identifier">mp_number</span> <span class="keyword">operator</span><span class="special">--(</span><span class="keyword">int</span><span class="special">);</span>
+<span class="comment">// Integer only operations:</span>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
+<span class="identifier">mp_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>
</pre>
<p>
- The following arithmetic operations are support for real-numbered types:
+ These operators all take their usual arithmetic meanings.
+ </p>
+<p>
+ The arguments to these operators is either:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
- Binary +, -, *, /, +<code class="literal">, -</code>, *<code class="literal">, /</code>,
- ==, !<code class="literal">, <</code>, ><code class="literal">, <, >, ||, &&,
- ||</code>, &&=.
+ Another <code class="computeroutput"><span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">></span></code>.
</li>
<li class="listitem">
- Unary +, -, ++, --, !.
+ A builtin arithmetic type.
+ </li>
+<li class="listitem">
+ An expression template derived from <code class="computeroutput"><span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">></span></code>.
</li>
</ul></div>
<p>
- For integer types the following operators are also supported:
- </p>
-<p>
- Binary %, %<code class="literal">, |, |</code>, &, &<code class="literal">, ^, ^</code>,
- <<, <<<code class="literal">, >>, >></code>.
- </p>
-<p>
- Note that with the exception of the logical operators and unary + the result
- of applying an operator to mp_number is an "unmentionable" expression
- template type.
- </p>
-<p>
- Binary operators, must have at least one argument that is of type <code class="computeroutput"><span class="identifier">mp_number</span></code> or an expression template derived
- from <code class="computeroutput"><span class="identifier">mp_number</span></code>. One argument
- may optionally be of arithmetic type.
- </p>
-<p>
- Note that type <code class="computeroutput"><span class="identifier">mp_number</span></code>
- (and all expression templates derived from it) may be used in a Boolian context.
+ For the left and right shift operations, the argument must be a builtin integer
+ type with a positive value (negative values result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code>
+ being thrown).
</p>
<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>
</pre>
@@ -203,6 +240,12 @@
or as an argument to a logical operator - without type <code class="computeroutput"><span class="identifier">mp_number</span></code>
being convertible to type <code class="computeroutput"><span class="keyword">bool</span></code>.
</p>
+<p>
+ This operator also enables the use of <code class="computeroutput"><span class="identifier">mp_number</span></code>
+ with any of the following operators: <code class="computeroutput"><span class="special">!</span></code>,
+ <code class="computeroutput"><span class="special">||</span></code>, <code class="computeroutput"><span class="special">&&</span></code>
+ and <code class="computeroutput"><span class="special">?:</span></code>.
+ </p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">mp_number</span><span class="special">&</span> <span class="identifier">other</span><span class="special">);</span>
</pre>
<p>
@@ -257,24 +300,80 @@
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
- A value less that 0 for *this < other
+ 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>
</li>
<li class="listitem">
- A value greater that 0 for *this > other
+ 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>
</li>
<li class="listitem">
- Zero for *this == other
+ Zero for <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span>
+ <span class="special">==</span> <span class="identifier">other</span></code>
</li>
</ul></div>
<pre class="programlisting"><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="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>
</pre>
<p>
- Returns the underlying backend instance used by *this.
+ Returns the underlying backend instance used by <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>.
</p>
-<a name="boost_multiprecision.ref.mp_number.swap"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.swap-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.swap">swap</a>
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h2"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.non_member_operators"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.non_member_operators">Non-member
+ operators</a>
+ </h5>
+<pre class="programlisting"><span class="comment">// Non member operators:</span>
+<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>
+<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>
+<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>
+<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>
+<span class="comment">// Integer only operations:</span>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+<span class="comment">// Comparison operators:</span>
+<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>
+<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>
+<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>
+<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>
+<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>
+<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>
+</pre>
+<p>
+ These operators all take their usual arithmetic meanings.
+ </p>
+<p>
+ The arguments to these functions must contain at least one of the following:
+ </p>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+ An <code class="computeroutput"><span class="identifier">mp_number</span></code>.
+ </li>
+<li class="listitem">
+ An expression template type derived from <code class="computeroutput"><span class="identifier">mp_number</span></code>.
+ </li>
+</ul></div>
+<p>
+ In addition, one of the two arguments may be a builtin arithmetic type.
+ </p>
+<p>
+ With the exception of the comparison operators (which always evaluate their
+ arguments and return a <code class="computeroutput"><span class="keyword">bool</span></code>
+ result), these operators return an "unmentionable" expression template
+ type which defers evaluation of the operator until the result is actually
+ required.
+ </p>
+<p>
+ Finally note that the second argument to the left and right shift operations
+ must be a builtin integer type, and that the argument must be positive (negative
+ arguments result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code>
+ being thrown).
+ </p>
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h3"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.swap"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.swap">swap</a>
</h5>
<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">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>&</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">Backend</span><span class="special">>&</span> <span class="identifier">b</span><span class="special">);</span>
@@ -282,9 +381,9 @@
<p>
Swaps <code class="computeroutput"><span class="identifier">a</span></code> and <code class="computeroutput"><span class="identifier">b</span></code>.
</p>
-<a name="boost_multiprecision.ref.mp_number.iostream_support"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.iostream_support-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.iostream_support">Iostream
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h4"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.iostream_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.iostream_support">Iostream
Support</a>
</h5>
<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>
@@ -298,9 +397,14 @@
These operators provided formatted input-output operations on <code class="computeroutput"><span class="identifier">mp_number</span></code> types, and expression templates
derived from them.
</p>
-<a name="boost_multiprecision.ref.mp_number.non_member_standard_library_function_support"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.non_member_standard_library_function_support-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.non_member_standard_library_function_support">Non-member
+<p>
+ It's down to the backend type to actually implement string conversion. However,
+ the backends provided with this library support all of the iostream formatting
+ flags, field width and precision settings.
+ </p>
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h5"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.non_member_standard_library_function_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.non_member_standard_library_function_support">Non-member
standard library function support</a>
</h5>
<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>mp_number-or-expression-template-type</em></span><span class="special">&);</span>
@@ -351,30 +455,34 @@
</p>
<p>
Also note that with the exception of <code class="computeroutput"><span class="identifier">abs</span></code>
- that these functions can only be used with floating point Backend types.
+ that these functions can only be used with floating-point Backend types.
</p>
-<a name="boost_multiprecision.ref.mp_number.boost_math_interoperabilty_support"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.boost_math_interoperabilty_support-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.boost_math_interoperabilty_support">Boost.Math
- Interoperabilty Support</a>
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h6"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.boost_math_interoperability_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.boost_math_interoperability_support">Boost.Math
+ Interoperability Support</a>
</h5>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>
-<span class="keyword">int</span> <span class="identifier">fpclassify</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">isfinite</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">isnan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">isinf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
-<span class="keyword">bool</span> <span class="identifier">isnormal</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
+<span class="keyword">int</span> <span class="identifier">fpclassify</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
+<span class="keyword">bool</span> <span class="identifier">isfinite</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
+<span class="keyword">bool</span> <span class="identifier">isnan</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
+<span class="keyword">bool</span> <span class="identifier">isinf</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
+<span class="keyword">bool</span> <span class="identifier">isnormal</span> <span class="special">(</span><span class="keyword">const</span> <span class="emphasis"><em>mp_number-or-expression-template-type</em></span><span class="special">&,</span> <span class="keyword">int</span><span class="special">);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<p>
- These functions behave exacts as their Boost.Math equivalents. Other Boost.Math
- functions and templates may also be specialized or overloaded to ensure interoperability.
+ These floating-point classification functions behave exactly as their Boost.Math
+ equivalents.
+ </p>
+<p>
+ Other Boost.Math functions and templates may also be specialized or overloaded
+ to ensure interoperability.
</p>
-<a name="boost_multiprecision.ref.mp_number.std__numeric_limits_support"></a><h5>
-<a name="boost_multiprecision.ref.mp_number.std__numeric_limits_support-heading"></a>
- <a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.std__numeric_limits_support">std::numeric_limits
+<h5>
+<a name="boost_multiprecision.ref.mp_number.h7"></a>
+ <span><a name="boost_multiprecision.ref.mp_number.std__numeric_limits_support"></a></span><a class="link" href="mp_number.html#boost_multiprecision.ref.mp_number.std__numeric_limits_support">std::numeric_limits
support</a>
</h5>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">{</span>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/ints.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -63,7 +63,8 @@
</p>
</th>
</tr></thead>
-<tbody><tr>
+<tbody>
+<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">gmp_int</span></code>
@@ -94,11 +95,44 @@
Dependency on GNU licenced GMP library.
</p>
</td>
-</tr></tbody>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">mp_int</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ boost/multiprecision/tommath.hpp
+ </p>
+ </td>
+<td>
+ <p>
+ 2
+ </p>
+ </td>
+<td>
+ <p>
+ libtommath
+ </p>
+ </td>
+<td>
+ <p>
+ Public domain backend with no licence restrictions.
+ </p>
+ </td>
+<td>
+ <p>
+ Slower than GMP.
+ </p>
+ </td>
+</tr>
+</tbody>
</table></div>
-<a name="boost_multiprecision.tut.ints.gmp_int"></a><h5>
-<a name="boost_multiprecision.tut.ints.gmp_int-heading"></a>
- <a class="link" href="ints.html#boost_multiprecision.tut.ints.gmp_int">gmp_int</a>
+<h5>
+<a name="boost_multiprecision.tut.ints.h0"></a>
+ <span><a name="boost_multiprecision.tut.ints.gmp_int"></a></span><a class="link" href="ints.html#boost_multiprecision.tut.ints.gmp_int">gmp_int</a>
</h5>
<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>
@@ -118,7 +152,7 @@
<p>
As well as the usual conversions from arithmetic and string types, type
<code class="computeroutput"><span class="identifier">mpz_int</span></code> is copy constructible
- and asignable from:
+ and assignable from:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
@@ -132,14 +166,26 @@
</ul></div>
<p>
It's also possible to access the underlying <code class="computeroutput"><span class="identifier">mpz_t</span></code>
- via the data() member function of <code class="computeroutput"><span class="identifier">gmp_int</span></code>.
+ via the <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code>
+ member function of <code class="computeroutput"><span class="identifier">gmp_int</span></code>.
</p>
-<a name="boost_multiprecision.tut.ints.example_"></a><h6>
-<a name="boost_multiprecision.tut.ints.example_-heading"></a>
- <a class="link" href="ints.html#boost_multiprecision.tut.ints.example_">Example:</a>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Formatted IO for this type does not support octal or hexadecimal notation
+ for negative values, as a result performing formatted output on this type
+ when the argument is negative and either of the flags <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">oct</span></code>
+ or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">hex</span></code> are set, will result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code> will be thrown.
+ </p></td></tr>
+</table></div>
+<h6>
+<a name="boost_multiprecision.tut.ints.h1"></a>
+ <span><a name="boost_multiprecision.tut.ints.example_"></a></span><a class="link" href="ints.html#boost_multiprecision.tut.ints.example_">Example:</a>
</h6>
<p>
-
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">gmp</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
@@ -160,6 +206,91 @@
</pre>
<p>
</p>
+<h5>
+<a name="boost_multiprecision.tut.ints.h2"></a>
+ <span><a name="boost_multiprecision.tut.ints.mp_int"></a></span><a class="link" href="ints.html#boost_multiprecision.tut.ints.mp_int">mp_int</a>
+ </h5>
+<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>
+
+<span class="keyword">class</span> <span class="identifier">tommath_int</span><span class="special">;</span>
+
+<span class="keyword">typedef</span> <span class="identifier">mp_number</span><span class="special"><</span><span class="identifier">tommath_int</span> <span class="special">></span> <span class="identifier">mp_int</span><span class="special">;</span>
+
+<span class="special">}}</span> <span class="comment">// namespaces</span>
+</pre>
+<p>
+ The <code class="computeroutput"><span class="identifier">tommath_int</span></code> backend is
+ used via the typedef <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">mp_int</span></code>.
+ It acts as a thin wrapper around the libtommath <code class="computeroutput"><span class="identifier">mp_int</span></code>
+ to provide an integer type that is a drop-in replacement for the native C++
+ integer types, but with unlimited precision.
+ </p>
+<div class="caution"><table border="0" summary="Caution">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="../../images/caution.png"></td>
+<th align="left">Caution</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Although <code class="computeroutput"><span class="identifier">mp_int</span></code> is mostly
+ a drop in replacement for the builtin integer types, it should be noted
+ that it is a rather strange beast as it's a signed type that is not a 2's
+ complement type. As a result the bitwise operations <code class="computeroutput"><span class="special">|</span>
+ <span class="special">&</span> <span class="special">^</span></code>
+ will throw a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code> exception if either of
+ the arguments is negative. Similarly the complement operator<code class="computeroutput"><span class="special">~</span></code> is deliberately not implemented for this
+ type.
+ </p></td></tr>
+</table></div>
+<div class="note"><table border="0" summary="Note">
+<tr>
+<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../images/note.png"></td>
+<th align="left">Note</th>
+</tr>
+<tr><td align="left" valign="top"><p>
+ Formatted IO for this type does not support octal or hexadecimal notation
+ for negative values, as a result performing formatted output on this type
+ when the argument is negative and either of the flags <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">oct</span></code>
+ or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">hex</span></code> are set, will result in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span></code> will be thrown.
+ </p></td></tr>
+</table></div>
+<h6>
+<a name="boost_multiprecision.tut.ints.h3"></a>
+ <span><a name="boost_multiprecision.tut.ints.example0"></a></span><a class="link" href="ints.html#boost_multiprecision.tut.ints.example0">Example:</a>
+ </h6>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">tommath</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+
+<span class="identifier">boost</span><span class="special">::</span><span class="identifier">multiprecision</span><span class="special">::</span><span class="identifier">mp_int</span> <span class="identifier">v</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
+
+<span class="comment">// Do some arithmetic:</span>
+<span class="keyword">for</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><=</span> <span class="number">1000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
+ <span class="identifier">v</span> <span class="special">*=</span> <span class="identifier">i</span><span class="special">;</span>
+
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">v</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 1000!</span>
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">hex</span> <span class="special"><<</span> <span class="identifier">v</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// prints 1000! in hex format</span>
+
+<span class="keyword">try</span><span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">hex</span> <span class="special"><<</span> <span class="special">-</span><span class="identifier">v</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// Ooops! can't print a negative value in hex format!</span>
+<span class="special">}</span>
+<span class="keyword">catch</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span><span class="special">&</span> <span class="identifier">e</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="special">}</span>
+
+<span class="keyword">try</span><span class="special">{</span>
+ <span class="comment">// v is not a 2's complement type, bitwise operations are only supported</span>
+ <span class="comment">// on positive values:</span>
+ <span class="identifier">v</span> <span class="special">=</span> <span class="special">-</span><span class="identifier">v</span> <span class="special">&</span> <span class="number">2</span><span class="special">;</span>
+<span class="special">}</span>
+<span class="keyword">catch</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">runtime_error</span><span class="special">&</span> <span class="identifier">e</span><span class="special">)</span>
+<span class="special">{</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">e</span><span class="special">.</span><span class="identifier">what</span><span class="special">()</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
+<span class="special">}</span>
+
+</pre>
+<p>
+ </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/rational.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/rational.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/rational.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -96,9 +96,9 @@
</td>
</tr></tbody>
</table></div>
-<a name="boost_multiprecision.tut.rational.gmp_rational"></a><h5>
-<a name="boost_multiprecision.tut.rational.gmp_rational-heading"></a>
- <a class="link" href="rational.html#boost_multiprecision.tut.rational.gmp_rational">gmp_rational</a>
+<h5>
+<a name="boost_multiprecision.tut.rational.h0"></a>
+ <span><a name="boost_multiprecision.tut.rational.gmp_rational"></a></span><a class="link" href="rational.html#boost_multiprecision.tut.rational.gmp_rational">gmp_rational</a>
</h5>
<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>
@@ -136,18 +136,18 @@
<span class="identifier">mpz_int</span> <span class="identifier">denominator</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">mpq_rational</span><span class="special">&);</span>
</pre>
<p>
- Which return the numerator and denominator of the number.
+ which return the numerator and denominator of the number.
</p>
<p>
It's also possible to access the underlying <code class="computeroutput"><span class="identifier">mpq_t</span></code>
- via the data() member function of <code class="computeroutput"><span class="identifier">mpq_rational</span></code>.
+ via the <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code>
+ member function of <code class="computeroutput"><span class="identifier">mpq_rational</span></code>.
</p>
-<a name="boost_multiprecision.tut.rational.example_"></a><h6>
-<a name="boost_multiprecision.tut.rational.example_-heading"></a>
- <a class="link" href="rational.html#boost_multiprecision.tut.rational.example_">Example:</a>
+<h6>
+<a name="boost_multiprecision.tut.rational.h1"></a>
+ <span><a name="boost_multiprecision.tut.rational.example_"></a></span><a class="link" href="rational.html#boost_multiprecision.tut.rational.example_">Example:</a>
</h6>
<p>
-
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">gmp</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
Modified: sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/boost_multiprecision/tut/reals.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -119,7 +119,7 @@
</td>
<td>
<p>
- Very fast and efficient backend, with it's own standard library
+ Very fast and efficient backend, with its own standard library
implementation.
</p>
</td>
@@ -152,7 +152,7 @@
</td>
<td>
<p>
- Header only, all C++ implementation.
+ Header only, all C++ implementation. Boost licence.
</p>
</td>
<td>
@@ -163,9 +163,9 @@
</tr>
</tbody>
</table></div>
-<a name="boost_multiprecision.tut.reals.gmp_float"></a><h5>
-<a name="boost_multiprecision.tut.reals.gmp_float-heading"></a>
- <a class="link" href="reals.html#boost_multiprecision.tut.reals.gmp_float">gmp_float</a>
+<h5>
+<a name="boost_multiprecision.tut.reals.h0"></a>
+ <span><a name="boost_multiprecision.tut.reals.gmp_float"></a></span><a class="link" href="reals.html#boost_multiprecision.tut.reals.gmp_float">gmp_float</a>
</h5>
<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>
@@ -182,8 +182,8 @@
</pre>
<p>
The <code class="computeroutput"><span class="identifier">gmp_float</span></code> backend is
- used in conjunction with <code class="computeroutput"><span class="identifier">mp_number</span></code>:
- It acts as a thin wrapper around the GMP <code class="computeroutput"><span class="identifier">mpf_t</span></code>
+ used in conjunction with <code class="computeroutput"><span class="identifier">mp_number</span></code>
+ : it acts as a thin wrapper around the GMP <code class="computeroutput"><span class="identifier">mpf_t</span></code>
to provide an real-number type that is a drop-in replacement for the native
C++ floating-point types, but with much greater precision.
</p>
@@ -226,14 +226,15 @@
</ul></div>
<p>
It's also possible to access the underlying <code class="computeroutput"><span class="identifier">mpf_t</span></code>
- via the data() member function of <code class="computeroutput"><span class="identifier">gmp_float</span></code>.
+ via the <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code>
+ member function of <code class="computeroutput"><span class="identifier">gmp_float</span></code>.
</p>
-<a name="boost_multiprecision.tut.reals.gmp_example_"></a><h6>
-<a name="boost_multiprecision.tut.reals.gmp_example_-heading"></a>
- <a class="link" href="reals.html#boost_multiprecision.tut.reals.gmp_example_">GMP example:</a>
+<h6>
+<a name="boost_multiprecision.tut.reals.h1"></a>
+ <span><a name="boost_multiprecision.tut.reals.gmp_example_"></a></span><a class="link" href="reals.html#boost_multiprecision.tut.reals.gmp_example_">GMP
+ example:</a>
</h6>
<p>
-
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">gmp</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
@@ -257,9 +258,9 @@
</pre>
<p>
</p>
-<a name="boost_multiprecision.tut.reals.mpfr_float"></a><h5>
-<a name="boost_multiprecision.tut.reals.mpfr_float-heading"></a>
- <a class="link" href="reals.html#boost_multiprecision.tut.reals.mpfr_float">mpfr_float</a>
+<h5>
+<a name="boost_multiprecision.tut.reals.h2"></a>
+ <span><a name="boost_multiprecision.tut.reals.mpfr_float"></a></span><a class="link" href="reals.html#boost_multiprecision.tut.reals.mpfr_float">mpfr_float</a>
</h5>
<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>
@@ -324,12 +325,12 @@
It's also possible to access the underlying <code class="computeroutput"><span class="identifier">mpf_t</span></code>
via the data() member function of <code class="computeroutput"><span class="identifier">gmp_float</span></code>.
</p>
-<a name="boost_multiprecision.tut.reals.mpfr_example_"></a><h6>
-<a name="boost_multiprecision.tut.reals.mpfr_example_-heading"></a>
- <a class="link" href="reals.html#boost_multiprecision.tut.reals.mpfr_example_">MPFR example:</a>
+<h6>
+<a name="boost_multiprecision.tut.reals.h3"></a>
+ <span><a name="boost_multiprecision.tut.reals.mpfr_example_"></a></span><a class="link" href="reals.html#boost_multiprecision.tut.reals.mpfr_example_">MPFR
+ example:</a>
</h6>
<p>
-
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">mpfr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
@@ -353,9 +354,9 @@
</pre>
<p>
</p>
-<a name="boost_multiprecision.tut.reals.cpp_float"></a><h5>
-<a name="boost_multiprecision.tut.reals.cpp_float-heading"></a>
- <a class="link" href="reals.html#boost_multiprecision.tut.reals.cpp_float">cpp_float</a>
+<h5>
+<a name="boost_multiprecision.tut.reals.h4"></a>
+ <span><a name="boost_multiprecision.tut.reals.cpp_float"></a></span><a class="link" href="reals.html#boost_multiprecision.tut.reals.cpp_float">cpp_float</a>
</h5>
<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>
@@ -384,13 +385,12 @@
There is full standard library and <code class="computeroutput"><span class="identifier">numeric_limits</span></code>
support available for this type.
</p>
-<a name="boost_multiprecision.tut.reals.cpp_float_example_"></a><h6>
-<a name="boost_multiprecision.tut.reals.cpp_float_example_-heading"></a>
- <a class="link" href="reals.html#boost_multiprecision.tut.reals.cpp_float_example_">cpp_float
+<h6>
+<a name="boost_multiprecision.tut.reals.h5"></a>
+ <span><a name="boost_multiprecision.tut.reals.cpp_float_example_"></a></span><a class="link" href="reals.html#boost_multiprecision.tut.reals.cpp_float_example_">cpp_float
example:</a>
</h6>
<p>
-
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">multiprecision</span><span class="special">/</span><span class="identifier">cpp_float</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
Modified: sandbox/big_number/libs/multiprecision/doc/html/index.html
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/html/index.html (original)
+++ sandbox/big_number/libs/multiprecision/doc/html/index.html 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -20,7 +20,7 @@
</h3></div></div>
<div><p class="copyright">Copyright © 2011 John Maddock</p></div>
<div><div class="legalnotice">
-<a name="id992912"></a><p>
+<a name="boost_multiprecision.legal"></a><p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
</p>
@@ -45,7 +45,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: July 08, 2011 at 18:51:46 +0100</small></p></td>
+<td align="left"><p><small>Last revised: November 29, 2011 at 19:27:45 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk
==============================================================================
--- sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk (original)
+++ sandbox/big_number/libs/multiprecision/doc/multiprecision.qbk 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -21,6 +21,7 @@
[import ../example/gmp_snips.cpp]
[import ../example/mpfr_snips.cpp]
[import ../example/cpp_float_snips.cpp]
+[import ../example/tommath_snips.cpp]
[section:intro Introduction]
@@ -199,6 +200,7 @@
[table
[[Backend Type][Header][Radix][Dependencies][Pros][Cons]]
[[`gmp_int`][boost/multiprecision/gmp.hpp][2][GMP][Very fast and efficient backend.][Dependency on GNU licenced GMP library.]]
+[[`mp_int`][boost/multiprecision/tommath.hpp][2][libtommath][Public domain backend with no licence restrictions.][Slower than GMP.]]
]
[h4 gmp_int]
@@ -221,10 +223,40 @@
It's also possible to access the underlying `mpz_t` via the `data()` member function of `gmp_int`.
+[note Formatted IO for this type does not support octal or hexadecimal notation for negative values,
+as a result performing formatted output on this type when the argument is negative and either of the flags
+`std::ios_base::oct` or `std::ios_base::hex` are set, will result in a `std::runtime_error` will be thrown.]
+
[h5 Example:]
[mpz_eg]
+[h4 mp_int]
+
+ namespace boost{ namespace multiprecision{
+
+ class tommath_int;
+
+ typedef mp_number<tommath_int > mp_int;
+
+ }} // namespaces
+
+The `tommath_int` backend is used via the typedef `boost::multiprecision::mp_int`. It acts as a thin wrapper around the libtommath `mp_int`
+to provide an integer type that is a drop-in replacement for the native C++ integer types, but with unlimited precision.
+
+[caution Although `mp_int` is mostly a drop in replacement for the builtin integer types, it should be noted that it is a
+rather strange beast as it's a signed type that is not a 2's complement type. As a result the bitwise operations
+`| & ^` will throw a `std::runtime_error` exception if either of the arguments is negative. Similarly the complement
+operator`~` is deliberately not implemented for this type.]
+
+[note Formatted IO for this type does not support octal or hexadecimal notation for negative values,
+as a result performing formatted output on this type when the argument is negative and either of the flags
+`std::ios_base::oct` or `std::ios_base::hex` are set, will result in a `std::runtime_error` will be thrown.]
+
+[h5 Example:]
+
+[tommath_eg]
+
[endsect]
[section:reals Real Numbers]
@@ -405,7 +437,22 @@
mp_number(see-below);
mp_number& operator=(see-below);
- /* Other number-type operators here */
+ // Member operators
+ mp_number& operator+=(const ``['see-below]``&);
+ mp_number& operator-=(const ``['see-below]``&);
+ mp_number& operator*=(const ``['see-below]``&);
+ mp_number& operator/=(const ``['see-below]``&);
+ mp_number& operator++();
+ mp_number& operator--();
+ mp_number operator++(int);
+ mp_number operator--(int);
+
+ mp_number& operator%=(const ``['see-below]``&);
+ mp_number& operator&=(const ``['see-below]``&);
+ mp_number& operator|=(const ``['see-below]``&);
+ mp_number& operator^=(const ``['see-below]``&);
+ mp_number& operator<<=(const ``['integer-type]``&);
+ mp_number& operator>>=(const ``['integer-type]``&);
// Use in Boolean context:
operator ``['convertible-to-bool-type]``()const;
@@ -433,6 +480,26 @@
const Backend& backend()const;
};
+ // Non member operators:
+ ``['unmentionable-expression-template-type]`` operator+(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator-(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator*(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator/(const ``['see-below]``&, const ``['see-below]``&);
+ // Integer only operations:
+ ``['unmentionable-expression-template-type]`` operator%(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator&(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator|(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator^(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator<<(const ``['see-below]``&, const ``['integer-type]``&);
+ ``['unmentionable-expression-template-type]`` operator>>(const ``['see-below]``&, const ``['integer-type]``&);
+ // Comparison operators:
+ bool operator==(const ``['see-below]``&, const ``['see-below]``&);
+ bool operator!=(const ``['see-below]``&, const ``['see-below]``&);
+ bool operator< (const ``['see-below]``&, const ``['see-below]``&);
+ bool operator> (const ``['see-below]``&, const ``['see-below]``&);
+ bool operator<=(const ``['see-below]``&, const ``['see-below]``&);
+ bool operator>=(const ``['see-below]``&, const ``['see-below]``&);
+
// Swap:
template <class Backend>
void swap(mp_number<Backend>& a, mp_number<Backend>& b);
@@ -515,24 +582,32 @@
* A `std::string` or any type which is convertible to `const char*`.
* Any type that the Backend is constructible or assignable from.
- /* Other number-type operators here */
-
-The following arithmetic operations are support for real-numbered types:
-
-* Binary +, -, *, /, +=, -=, *=, /=, ==, !=, <=, >=, <, >, ||, &&, ||=, &&=.
-* Unary +, -, ++, --, !.
-
-For integer types the following operators are also supported:
-
-Binary %, %=, |, |=, &, &=, ^, ^=, <<, <<=, >>, >>=.
-
-Note that with the exception of the logical operators and unary + the result of applying an operator to
-mp_number is an "unmentionable" expression template type.
+ mp_number& operator+=(const ``['see-below]``&);
+ mp_number& operator-=(const ``['see-below]``&);
+ mp_number& operator*=(const ``['see-below]``&);
+ mp_number& operator/=(const ``['see-below]``&);
+ mp_number& operator++();
+ mp_number& operator--();
+ mp_number operator++(int);
+ mp_number operator--(int);
+ // Integer only operations:
+ mp_number& operator%=(const ``['see-below]``&);
+ mp_number& operator&=(const ``['see-below]``&);
+ mp_number& operator|=(const ``['see-below]``&);
+ mp_number& operator^=(const ``['see-below]``&);
+ mp_number& operator<<=(const ``['integer-type]``&);
+ mp_number& operator>>=(const ``['integer-type]``&);
+
+These operators all take their usual arithmetic meanings.
+
+The arguments to these operators is either:
+
+* Another `mp_number<Backend>`.
+* A builtin arithmetic type.
+* An expression template derived from `mp_number<Backend>`.
-Binary operators, must have at least one argument that is of type `mp_number` or an expression template
-derived from `mp_number`. One argument may optionally be of arithmetic type.
-
-Note that type `mp_number` (and all expression templates derived from it) may be used in a Boolean context.
+For the left and right shift operations, the argument must be a builtin
+integer type with a positive value (negative values result in a `std::runtime_error` being thrown).
operator ``['convertible-to-bool-type]``()const;
@@ -540,6 +615,9 @@
Boolean context - if statements, conditional statements, or as an argument to a logical operator - without
type `mp_number` being convertible to type `bool`.
+This operator also enables the use of `mp_number` with any of the following operators:
+`!`, `||`, `&&` and `?:`.
+
void swap(mp_number& other);
Swaps `*this` with `other`.
@@ -588,6 +666,44 @@
Returns the underlying backend instance used by `*this`.
+[h4 Non-member operators]
+
+ // Non member operators:
+ ``['unmentionable-expression-template-type]`` operator+(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator-(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator*(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator/(const ``['see-below]``&, const ``['see-below]``&);
+ // Integer only operations:
+ ``['unmentionable-expression-template-type]`` operator%(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator&(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator|(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator^(const ``['see-below]``&, const ``['see-below]``&);
+ ``['unmentionable-expression-template-type]`` operator<<(const ``['see-below]``&, const ``['integer-type]``&);
+ ``['unmentionable-expression-template-type]`` operator>>(const ``['see-below]``&, const ``['integer-type]``&);
+ // Comparison operators:
+ bool operator==(const ``['see-below]``&, const ``['see-below]``&);
+ bool operator!=(const ``['see-below]``&, const ``['see-below]``&);
+ bool operator< (const ``['see-below]``&, const ``['see-below]``&);
+ bool operator> (const ``['see-below]``&, const ``['see-below]``&);
+ bool operator<=(const ``['see-below]``&, const ``['see-below]``&);
+ bool operator>=(const ``['see-below]``&, const ``['see-below]``&);
+
+These operators all take their usual arithmetic meanings.
+
+The arguments to these functions must contain at least one of the following:
+
+* An `mp_number`.
+* An expression template type derived from `mp_number`.
+
+In addition, one of the two arguments may be a builtin arithmetic type.
+
+With the exception of the comparison operators (which always evaluate their arguments and return a `bool` result),
+these operators return an "unmentionable" expression template type which defers evaluation of the operator
+until the result is actually required.
+
+Finally note that the second argument to the left and right shift operations must be a builtin integer type,
+and that the argument must be positive (negative arguments result in a `std::runtime_error` being thrown).
+
[h4 swap]
template <class Backend>
@@ -606,6 +722,9 @@
These operators provided formatted input-output operations on `mp_number` types, and expression templates derived from them.
+It's down to the backend type to actually implement string conversion. However, the backends provided with
+this library support all of the iostream formatting flags, field width and precision settings.
+
[h4 Non-member standard library function support]
``['unmentionable-expression-template-type]`` abs (const ``['mp_number-or-expression-template-type]``&);
@@ -743,6 +862,8 @@
[[`eval_floor(b, cb)`][`void`][Stores the floor of `cb` in `b`, only required when `B` is a floating-point type.]]
[[`eval_ceil(b, cb)`][`void`][Stores the ceiling of `cb` in `b`, only required when `B` is a floating-point type.]]
[[`eval_sqrt(b, cb)`][`void`][Stores the square root of `cb` in `b`, only required when `B` is a floating-point type.]]
+[[`boost::multiprecision::number_category<B>::type`][`mpl::int_<N>`][`N` is one of the values `number_kind_integer`, `number_kind_floating_point`, `number_kind_rational` or `number_kind_fixed_point`.
+ Defaults to `number_kind_floating_point`.]]
]
[table Optional Requirements on the Backend Type
Modified: sandbox/big_number/libs/multiprecision/test/Jamfile.v2
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/Jamfile.v2 (original)
+++ sandbox/big_number/libs/multiprecision/test/Jamfile.v2 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -506,20 +506,6 @@
: # requirements
[ check-target-builds ../config//has_mpfr : : <build>no ] ;
-run ../example/gmp_snips.cpp gmp
- : # command line
- : # input files
- : # requirements
- [ check-target-builds ../config//has_gmp : : <build>no ] ;
-
-run ../example/mpfr_snips.cpp mpfr
- : # command line
- : # input files
- : # requirements
- [ check-target-builds ../config//has_mpfr : : <build>no ] ;
-
-run ../example/cpp_float_snips.cpp ;
-
run test_round.cpp
: # command line
: # input files
@@ -622,3 +608,25 @@
<define>TEST_MPZ
[ check-target-builds ../config//has_gmp : : <build>no ]
: test_int_io_mpz ;
+
+run ../example/gmp_snips.cpp gmp
+ : # command line
+ : # input files
+ : # requirements
+ [ check-target-builds ../config//has_gmp : : <build>no ] ;
+
+run ../example/mpfr_snips.cpp mpfr
+ : # command line
+ : # input files
+ : # requirements
+ [ check-target-builds ../config//has_mpfr : : <build>no ] ;
+
+run ../example/cpp_float_snips.cpp ;
+
+run ../example/tommath_snips.cpp $(TOMMATH)
+ : # command line
+ : # input files
+ : # requirements
+ [ check-target-builds ../config//has_tommath : : <build>no ] ;
+
+
Modified: sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp (original)
+++ sandbox/big_number/libs/multiprecision/test/test_arithmetic.cpp 2011-11-30 07:08:59 EST (Wed, 30 Nov 2011)
@@ -86,6 +86,24 @@
struct is_twos_complement_integer<boost::multiprecision::mp_int> : public boost::mpl::false_ {};
#endif
+template <class Real>
+void test_complement(Real a, Real b, Real c, const boost::mpl::true_&)
+{
+ int i = 1020304;
+ int j = 56789123;
+ int sign_mask = ~0;
+ BOOST_TEST(~a == (~i & sign_mask));
+ c = a & ~b;
+ BOOST_TEST(c == (i & (~j & sign_mask)));
+ c = ~(a | b);
+ BOOST_TEST(c == (~(i | j) & sign_mask));
+}
+
+template <class Real>
+void test_complement(Real, Real, Real, const boost::mpl::false_&)
+{
+}
+
template <class Real, class T>
void test_integer_ops(const T&){}
@@ -196,7 +214,6 @@
int i = 1020304;
int j = 56789123;
int k = 4523187;
- int sign_mask = is_twos_complement_integer<Real>::value ? ~0 : (std::numeric_limits<int>::max)();
a = i;
b = j;
c = a;
@@ -219,6 +236,8 @@
c = a & b & k;
BOOST_TEST(c == (i&j&k));
+ test_complement<Real>(a, b, c, typename is_twos_complement_integer<Real>::type());
+
a = i;
b = j;
c = a;
@@ -265,11 +284,6 @@
a = i;
b = j;
c = k;
- BOOST_TEST(~a == (~i & sign_mask));
- c = a & ~b;
- BOOST_TEST(c == (i & (~j & sign_mask)));
- c = ~(a | b);
- BOOST_TEST(c == (~(i | j) & sign_mask));
//
// Non-member functions:
//
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk