1 | //
|
---|
2 | // boost_multiprecision_power_demo.cpp
|
---|
3 | //
|
---|
4 | // Created by Jan Bouwer on 9/7/13.
|
---|
5 |
|
---|
6 |
|
---|
7 | #include <cassert>
|
---|
8 | #include <cmath>
|
---|
9 | #include <iostream>
|
---|
10 | #include <boost/multiprecision/cpp_dec_float.hpp>
|
---|
11 |
|
---|
12 | template<class T>
|
---|
13 | void test_power_float(double e)
|
---|
14 | {
|
---|
15 | const T xb(-1), xe(e);
|
---|
16 | assert( xe > 0 );
|
---|
17 |
|
---|
18 | std::cout << "pow(-1, " << e << ") = " << pow(xb, xe) << std::endl;
|
---|
19 | }
|
---|
20 |
|
---|
21 | void test_boost_mp()
|
---|
22 | {
|
---|
23 | using namespace boost::multiprecision;
|
---|
24 |
|
---|
25 | test_power_float<cpp_dec_float_50>(0x8000000000000000u);
|
---|
26 | test_power_float<cpp_dec_float_50>(0x8000000000000001u);
|
---|
27 | test_power_float<cpp_dec_float_50>(0xFFFFFFFFFFFFFFFEu);
|
---|
28 | test_power_float<cpp_dec_float_50>(0xFFFFFFFFFFFFFFFFu);
|
---|
29 | test_power_float<cpp_dec_float_100>(0x8000000000000000u);
|
---|
30 | test_power_float<cpp_dec_float_100>(0x8000000000000001u);
|
---|
31 | test_power_float<cpp_dec_float_100>(0xFFFFFFFFFFFFFFFEu);
|
---|
32 | test_power_float<cpp_dec_float_100>(0xFFFFFFFFFFFFFFFFu);
|
---|
33 | }
|
---|