]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multiprecision/test/issue_13301.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2016 John Maddock. Distributed under the Boost
3 // Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/multiprecision/cpp_bin_float.hpp>
10 typedef boost::multiprecision::number
<boost::multiprecision::cpp_bin_float
<8, boost::multiprecision::backends::digit_base_2
> > quarter_float
;
12 quarter_float
qf(256);
14 unsigned int ui
= qf
.convert_to
<unsigned int>();
18 std::uintmax_t m(1), n
;
19 m
<<= std::numeric_limits
<std::uintmax_t>::digits
- 1;
21 n
= qf
.convert_to
<std::uintmax_t>();
25 n
= qf
.convert_to
<std::uintmax_t>();
26 m
= (std::numeric_limits
<std::uintmax_t>::max
)();
31 int si
= qf
.convert_to
<int>();
34 std::intmax_t sm(1), sn
;
35 sm
<<= std::numeric_limits
<std::intmax_t>::digits
- 1;
37 sn
= qf
.convert_to
<std::intmax_t>();
41 sn
= qf
.convert_to
<std::intmax_t>();
42 sm
= (std::numeric_limits
<std::intmax_t>::max
)();
46 // Again with negative numbers:
48 si
= qf
.convert_to
<int>();
52 sm
<<= std::numeric_limits
<std::intmax_t>::digits
- 1;
55 sn
= qf
.convert_to
<std::intmax_t>();
59 sn
= qf
.convert_to
<std::intmax_t>();
60 sm
= (std::numeric_limits
<std::intmax_t>::min
)();
64 // Now try conversion to cpp_int:
66 boost::multiprecision::cpp_int i
= qf
.convert_to
<boost::multiprecision::cpp_int
>(), j
;
70 i
= qf
.convert_to
<boost::multiprecision::cpp_int
>();