| 1 | #include <iostream>
 | 
|---|
| 2 | #include <iomanip>
 | 
|---|
| 3 | #include <boost/multiprecision/cpp_int.hpp>
 | 
|---|
| 4 | #include <boost/multiprecision/cpp_bin_float.hpp>
 | 
|---|
| 5 | 
 | 
|---|
| 6 | using namespace boost::multiprecision;
 | 
|---|
| 7 | 
 | 
|---|
| 8 | typedef number<cpp_bin_float<8,backends::digit_base_2> > quarter_float;
 | 
|---|
| 9 | 
 | 
|---|
| 10 | 
 | 
|---|
| 11 | int 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 | }
 | 
|---|