Ticket #13301: bmc.cc

File bmc.cc, 1.0 KB (added by marc.alexa@…, 5 years ago)
Line 
1#include <iostream>
2#include <iomanip>
3#include <boost/multiprecision/cpp_int.hpp>
4#include <boost/multiprecision/cpp_bin_float.hpp>
5
6using namespace boost::multiprecision;
7
8typedef number<cpp_bin_float<8,backends::digit_base_2> > quarter_float;
9
10
11int main(int argc, char *argv[])
12{
13 for (unsigned int i = 0; i < 16; i++)
14 {
15 unsigned int n = 1 << i;
16 std::cout << "uint: " << n << std::endl;
17
18 quarter_float qf(n);
19 std::cout << "quarter float: " << qf << std::endl;
20
21 unsigned int ui_qf = qf.convert_to<unsigned int>();
22 std::cout << "converted to uint: " << ui_qf << std::endl;
23
24 cpp_int bmi_convert_qf = qf.convert_to<cpp_int>();
25 std::cout << "converted to cpp_int: " << bmi_convert_qf << std::endl;
26
27 cpp_int bmi_sc_qf = static_cast<cpp_int>(qf);
28 std::cout << "static cast to cpp_int: " << bmi_convert_qf << std::endl;
29
30 double d_qf = qf.convert_to<double>();
31 std::cout << "converted to double: " << d_qf << std::endl;
32 }
33}