]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multiprecision/example/mpfi_snips.cpp
1 ///////////////////////////////////////////////////////////////
2 // Copyright 2011 John Maddock. Distributed under the Boost
3 // Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
7 #include <boost/multiprecision/mpfi.hpp>
8 #include <boost/math/special_functions/gamma.hpp>
13 using namespace boost::multiprecision
;
15 // Operations at variable precision and no numeric_limits support:
17 mpfi_float::default_precision(1000);
18 std::cout
<< mpfi_float::default_precision() << std::endl
;
19 std::cout
<< sqrt(a
) << std::endl
; // print root-2
21 // Operations at fixed precision and full numeric_limits support:
23 std::cout
<< std::numeric_limits
<mpfi_float_100
>::digits
<< std::endl
;
24 // We can use any C++ std lib function:
25 std::cout
<< log(b
) << std::endl
; // print log(2)
27 // Access the underlying data:
30 mpfi_set(r
, b
.backend().data());
32 // Construct some explicit intervals and perform set operations:
33 mpfi_float_50
i1(1, 2), i2(1.5, 2.5);
34 std::cout
<< intersect(i1
, i2
) << std::endl
;
35 std::cout
<< hull(i1
, i2
) << std::endl
;
36 std::cout
<< overlap(i1
, i2
) << std::endl
;
37 std::cout
<< subset(i1
, i2
) << std::endl
;