Ticket #8809: boost_multiprecision_power_demo2.cpp

File boost_multiprecision_power_demo2.cpp, 938 bytes (added by Jan Bouwer <JBouwer@…>, 9 years ago)

Demonstration of the error

Line 
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
12template<class T>
13void 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
21void 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}