Ticket #12196: infcnv_test.cpp

File infcnv_test.cpp, 502 bytes (added by Michael Shatz, 6 years ago)

demonstrates mistake in convert_to<double>() of special cpp_bin_float values

Line 
1#include <iostream>
2#include <boost/multiprecision/cpp_bin_float.hpp>
3
4typedef boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<128, boost::multiprecision::backends::digit_base_2> > ext_float_t;
5
6int main(int, char**) {
7 ext_float_t a0("1e500000000");
8 ext_float_t a = a0*a0; // +inf
9 ext_float_t b = a*0; // nan
10
11 std::cout
12 << a << " => " << a.convert_to<double>() << "\n"
13 << b << " => " << b.convert_to<double>() << "\n"
14 ;
15
16 return 0;
17}