Ticket #12167: div_test.cpp

File div_test.cpp, 505 bytes (added by Michael Shatz, 6 years ago)

demonstrate overflow/underflow of exponent during divison (cpp_bin_float)

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