Ticket #12195: inf_test.cpp

File inf_test.cpp, 540 bytes (added by Michael Shatz, 6 years ago)

demonstrate wrong sign of result of multiplication of infinity

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 aa = a*a; // +inf
10 ext_float_t m1 = -1;
11
12 std::cout
13 << aa << " * " << m1 << " = " << aa*m1 << "\n"
14 << m1 << " * " << aa << " = " << m1*aa << "\n"
15 << aa << " / " << m1 << " = " << aa/m1 << "\n"
16 ;
17
18 return 0;
19}