1 ///////////////////////////////////////////////////////////////
2 // Copyright 2013 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
6 #ifndef BOOST_MATH_CPP_BIN_FLOAT_HPP
7 #define BOOST_MATH_CPP_BIN_FLOAT_HPP
9 #include <boost/multiprecision/cpp_int.hpp>
10 #include <boost/multiprecision/integer.hpp>
11 #include <boost/math/special_functions/trunc.hpp>
12 #include <boost/multiprecision/detail/float_string_cvt.hpp>
15 // Some includes we need from Boost.Math, since we rely on that library to provide these functions:
17 #include <boost/math/special_functions/asinh.hpp>
18 #include <boost/math/special_functions/acosh.hpp>
19 #include <boost/math/special_functions/atanh.hpp>
20 #include <boost/math/special_functions/cbrt.hpp>
21 #include <boost/math/special_functions/expm1.hpp>
22 #include <boost/math/special_functions/gamma.hpp>
24 #ifdef BOOST_HAS_FLOAT128
29 namespace multiprecision {
40 #pragma warning(disable : 4522 6326) // multiple assignment operators specified, comparison of two constants
46 inline typename enable_if_c<is_unsigned<U>::value, bool>::type is_negative(U) { return false; }
48 inline typename disable_if_c<is_unsigned<S>::value, bool>::type is_negative(S s) { return s < 0; }
50 template <class Float, int, bool = number_category<Float>::value == number_kind_floating_point>
51 struct is_cpp_bin_float_implicitly_constructible_from_type
53 static const bool value = false;
56 template <class Float, int bit_count>
57 struct is_cpp_bin_float_implicitly_constructible_from_type<Float, bit_count, true>
59 static const bool value = (std::numeric_limits<Float>::digits <= (int)bit_count) && (std::numeric_limits<Float>::radix == 2) && std::numeric_limits<Float>::is_specialized
60 #ifdef BOOST_HAS_FLOAT128
61 && !boost::is_same<Float, __float128>::value
63 && (is_floating_point<Float>::value || is_number<Float>::value);
66 template <class Float, int, bool = number_category<Float>::value == number_kind_floating_point>
67 struct is_cpp_bin_float_explicitly_constructible_from_type
69 static const bool value = false;
72 template <class Float, int bit_count>
73 struct is_cpp_bin_float_explicitly_constructible_from_type<Float, bit_count, true>
75 static const bool value = (std::numeric_limits<Float>::digits > (int)bit_count) && (std::numeric_limits<Float>::radix == 2) && std::numeric_limits<Float>::is_specialized
76 #ifdef BOOST_HAS_FLOAT128
77 && !boost::is_same<Float, __float128>::value
84 template <unsigned Digits, digit_base_type DigitBase = digit_base_10, class Allocator = void, class Exponent = int, Exponent MinExponent = 0, Exponent MaxExponent = 0>
88 static const unsigned bit_count = DigitBase == digit_base_2 ? Digits : (Digits * 1000uL) / 301uL + (((Digits * 1000uL) % 301) ? 2u : 1u);
89 typedef cpp_int_backend<is_void<Allocator>::value ? bit_count : 0, bit_count, is_void<Allocator>::value ? unsigned_magnitude : signed_magnitude, unchecked, Allocator> rep_type;
90 typedef cpp_int_backend<is_void<Allocator>::value ? 2 * bit_count : 0, 2 * bit_count, is_void<Allocator>::value ? unsigned_magnitude : signed_magnitude, unchecked, Allocator> double_rep_type;
92 typedef typename rep_type::signed_types signed_types;
93 typedef typename rep_type::unsigned_types unsigned_types;
94 typedef boost::mpl::list<float, double, long double> float_types;
95 typedef Exponent exponent_type;
97 static const exponent_type max_exponent_limit = boost::integer_traits<exponent_type>::const_max - 2 * static_cast<exponent_type>(bit_count);
98 static const exponent_type min_exponent_limit = boost::integer_traits<exponent_type>::const_min + 2 * static_cast<exponent_type>(bit_count);
100 BOOST_STATIC_ASSERT_MSG(MinExponent >= min_exponent_limit, "Template parameter MinExponent is too negative for our internal logic to function correctly, sorry!");
101 BOOST_STATIC_ASSERT_MSG(MaxExponent <= max_exponent_limit, "Template parameter MaxExponent is too large for our internal logic to function correctly, sorry!");
102 BOOST_STATIC_ASSERT_MSG(MinExponent <= 0, "Template parameter MinExponent can not be positive!");
103 BOOST_STATIC_ASSERT_MSG(MaxExponent >= 0, "Template parameter MaxExponent can not be negative!");
105 static const exponent_type max_exponent = MaxExponent == 0 ? max_exponent_limit : MaxExponent;
106 static const exponent_type min_exponent = MinExponent == 0 ? min_exponent_limit : MinExponent;
108 static const exponent_type exponent_zero = max_exponent + 1;
109 static const exponent_type exponent_infinity = max_exponent + 2;
110 static const exponent_type exponent_nan = max_exponent + 3;
114 exponent_type m_exponent;
118 cpp_bin_float() BOOST_MP_NOEXCEPT_IF(noexcept(rep_type())) : m_data(), m_exponent(exponent_zero), m_sign(false) {}
120 cpp_bin_float(const cpp_bin_float& o) BOOST_MP_NOEXCEPT_IF(noexcept(rep_type(std::declval<const rep_type&>())))
121 : m_data(o.m_data), m_exponent(o.m_exponent), m_sign(o.m_sign) {}
123 template <unsigned D, digit_base_type B, class A, class E, E MinE, E MaxE>
124 cpp_bin_float(const cpp_bin_float<D, B, A, E, MinE, MaxE>& o, typename boost::enable_if_c<(bit_count >= cpp_bin_float<D, B, A, E, MinE, MaxE>::bit_count)>::type const* = 0)
128 template <unsigned D, digit_base_type B, class A, class E, E MinE, E MaxE>
129 explicit cpp_bin_float(const cpp_bin_float<D, B, A, E, MinE, MaxE>& o, typename boost::disable_if_c<(bit_count >= cpp_bin_float<D, B, A, E, MinE, MaxE>::bit_count)>::type const* = 0)
130 : m_exponent(o.exponent()), m_sign(o.sign())
134 template <class Float>
135 cpp_bin_float(const Float& f,
136 typename boost::enable_if_c<detail::is_cpp_bin_float_implicitly_constructible_from_type<Float, bit_count>::value>::type const* = 0)
137 : m_data(), m_exponent(0), m_sign(false)
139 this->assign_float(f);
142 template <class Float>
143 explicit cpp_bin_float(const Float& f,
144 typename boost::enable_if_c<detail::is_cpp_bin_float_explicitly_constructible_from_type<Float, bit_count>::value>::type const* = 0)
145 : m_data(), m_exponent(0), m_sign(false)
147 this->assign_float(f);
149 #ifdef BOOST_HAS_FLOAT128
150 template <class Float>
151 cpp_bin_float(const Float& f,
152 typename boost::enable_if_c<
153 boost::is_same<Float, __float128>::value && ((int)bit_count >= 113)>::type const* = 0)
154 : m_data(), m_exponent(0), m_sign(false)
156 this->assign_float(f);
158 template <class Float>
159 explicit cpp_bin_float(const Float& f,
160 typename boost::enable_if_c<
161 boost::is_same<Float, __float128>::value && ((int)bit_count < 113)>::type const* = 0)
162 : m_data(), m_exponent(0), m_sign(false)
164 this->assign_float(f);
167 cpp_bin_float& operator=(const cpp_bin_float& o) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<rep_type&>() = std::declval<const rep_type&>()))
170 m_exponent = o.m_exponent;
175 template <unsigned D, digit_base_type B, class A, class E, E MinE, E MaxE>
176 cpp_bin_float& operator=(const cpp_bin_float<D, B, A, E, MinE, MaxE>& f)
178 switch (eval_fpclassify(f))
181 m_data = limb_type(0);
183 m_exponent = exponent_zero;
186 m_data = limb_type(0);
188 m_exponent = exponent_nan;
192 m_data = limb_type(0);
194 m_exponent = exponent_infinity;
197 typename cpp_bin_float<D, B, A, E, MinE, MaxE>::rep_type b(f.bits());
198 this->exponent() = f.exponent() + (E)bit_count - (E)cpp_bin_float<D, B, A, E, MinE, MaxE>::bit_count;
199 this->sign() = f.sign();
200 copy_and_round(*this, b);
204 #ifdef BOOST_HAS_FLOAT128
205 template <class Float>
206 typename boost::enable_if_c<
207 (number_category<Float>::value == number_kind_floating_point)
208 //&& (std::numeric_limits<Float>::digits <= (int)bit_count)
209 && ((std::numeric_limits<Float>::radix == 2) || (boost::is_same<Float, __float128>::value)),
210 cpp_bin_float&>::type
211 operator=(const Float& f)
213 template <class Float>
214 typename boost::enable_if_c<
215 (number_category<Float>::value == number_kind_floating_point)
216 //&& (std::numeric_limits<Float>::digits <= (int)bit_count)
217 && (std::numeric_limits<Float>::radix == 2),
218 cpp_bin_float&>::type
219 operator=(const Float& f)
222 return assign_float(f);
225 #ifdef BOOST_HAS_FLOAT128
226 template <class Float>
227 typename boost::enable_if_c<boost::is_same<Float, __float128>::value, cpp_bin_float&>::type assign_float(Float f)
229 using default_ops::eval_add;
230 typedef typename boost::multiprecision::detail::canonical<int, cpp_bin_float>::type bf_int_type;
233 m_data = limb_type(0);
234 m_sign = (signbitq(f) > 0);
235 m_exponent = exponent_zero;
240 m_data = limb_type(0);
242 m_exponent = exponent_nan;
247 m_data = limb_type(0);
249 m_exponent = exponent_infinity;
259 typedef typename mpl::front<unsigned_types>::type ui_type;
260 m_data = static_cast<ui_type>(0u);
264 static const int bits = sizeof(int) * CHAR_BIT - 1;
271 int ipart = (int)truncq(f);
275 t = static_cast<bf_int_type>(ipart);
278 m_exponent += static_cast<Exponent>(e);
282 #ifdef BOOST_HAS_FLOAT128
283 template <class Float>
284 typename boost::enable_if_c<is_floating_point<Float>::value && !is_same<Float, __float128>::value, cpp_bin_float&>::type assign_float(Float f)
286 template <class Float>
287 typename boost::enable_if_c<is_floating_point<Float>::value, cpp_bin_float&>::type assign_float(Float f)
291 using default_ops::eval_add;
292 typedef typename boost::multiprecision::detail::canonical<int, cpp_bin_float>::type bf_int_type;
294 switch ((boost::math::fpclassify)(f))
297 m_data = limb_type(0);
298 m_sign = ((boost::math::signbit)(f) > 0);
299 m_exponent = exponent_zero;
302 m_data = limb_type(0);
304 m_exponent = exponent_nan;
307 m_data = limb_type(0);
309 m_exponent = exponent_infinity;
319 typedef typename mpl::front<unsigned_types>::type ui_type;
320 m_data = static_cast<ui_type>(0u);
324 static const int bits = sizeof(int) * CHAR_BIT - 1;
331 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
332 int ipart = itrunc(f);
334 int ipart = static_cast<int>(f);
339 t = static_cast<bf_int_type>(ipart);
342 m_exponent += static_cast<Exponent>(e);
346 template <class Float>
347 typename boost::enable_if_c<
348 (number_category<Float>::value == number_kind_floating_point) && !boost::is_floating_point<Float>::value && (number_category<Float>::value == number_kind_floating_point),
349 cpp_bin_float&>::type
350 assign_float(Float f)
353 using default_ops::eval_add;
354 using default_ops::eval_convert_to;
355 using default_ops::eval_get_sign;
356 using default_ops::eval_subtract;
358 typedef typename boost::multiprecision::detail::canonical<int, Float>::type f_int_type;
359 typedef typename boost::multiprecision::detail::canonical<int, cpp_bin_float>::type bf_int_type;
361 switch (eval_fpclassify(f))
364 m_data = limb_type(0);
365 m_sign = (eval_get_sign(f) > 0);
366 m_exponent = exponent_zero;
369 m_data = limb_type(0);
371 m_exponent = exponent_nan;
374 m_data = limb_type(0);
375 m_sign = eval_get_sign(f) < 0;
376 m_exponent = exponent_infinity;
379 if (eval_get_sign(f) < 0)
387 typedef typename mpl::front<unsigned_types>::type ui_type;
388 m_data = static_cast<ui_type>(0u);
392 static const int bits = sizeof(int) * CHAR_BIT - 1;
394 eval_frexp(f, f, &e);
395 while (eval_get_sign(f) != 0)
397 eval_ldexp(f, f, bits);
400 eval_convert_to(&ipart, f);
401 eval_subtract(f, static_cast<f_int_type>(ipart));
403 eval_add(*this, static_cast<bf_int_type>(ipart));
406 if (m_exponent > max_exponent)
407 m_exponent = exponent_infinity;
408 if (m_exponent < min_exponent)
410 m_data = limb_type(0u);
411 m_exponent = exponent_zero;
412 m_sign = (eval_get_sign(f) > 0);
414 else if (eval_get_sign(m_data) == 0)
416 m_exponent = exponent_zero;
417 m_sign = (eval_get_sign(f) > 0);
421 template <class B, expression_template_option et>
422 cpp_bin_float& assign_float(const number<B, et>& f)
424 return assign_float(f.backend());
428 typename boost::enable_if<is_integral<I>, cpp_bin_float&>::type operator=(const I& i)
430 using default_ops::eval_bit_test;
433 m_data = static_cast<limb_type>(0);
434 m_exponent = exponent_zero;
439 typedef typename make_unsigned<I>::type ui_type;
440 ui_type fi = static_cast<ui_type>(boost::multiprecision::detail::unsigned_abs(i));
441 typedef typename boost::multiprecision::detail::canonical<ui_type, rep_type>::type ar_type;
442 m_data = static_cast<ar_type>(fi);
443 unsigned shift = msb(fi);
444 if (shift >= bit_count)
446 m_exponent = static_cast<Exponent>(shift);
447 m_data = static_cast<ar_type>(fi >> (shift + 1 - bit_count));
451 m_exponent = static_cast<Exponent>(shift);
452 eval_left_shift(m_data, bit_count - shift - 1);
454 BOOST_ASSERT(eval_bit_test(m_data, bit_count - 1));
455 m_sign = detail::is_negative(i);
460 cpp_bin_float& operator=(const char* s);
462 void swap(cpp_bin_float& o) BOOST_NOEXCEPT
464 m_data.swap(o.m_data);
465 std::swap(m_exponent, o.m_exponent);
466 std::swap(m_sign, o.m_sign);
469 std::string str(std::streamsize dig, std::ios_base::fmtflags f) const;
473 if (m_exponent != exponent_nan)
477 int compare(const cpp_bin_float& o) const BOOST_NOEXCEPT
479 if (m_sign != o.m_sign)
480 return (m_exponent == exponent_zero) && (m_exponent == o.m_exponent) ? 0 : m_sign ? -1 : 1;
482 if (m_exponent == exponent_nan)
484 else if (m_exponent != o.m_exponent)
486 if (m_exponent == exponent_zero)
488 else if (o.m_exponent == exponent_zero)
491 result = m_exponent > o.m_exponent ? 1 : -1;
494 result = m_data.compare(o.m_data);
500 int compare(const A& o) const BOOST_NOEXCEPT
507 rep_type& bits() { return m_data; }
508 const rep_type& bits() const { return m_data; }
509 exponent_type& exponent() { return m_exponent; }
510 const exponent_type& exponent() const { return m_exponent; }
511 bool& sign() { return m_sign; }
512 const bool& sign() const { return m_sign; }
513 void check_invariants()
515 using default_ops::eval_bit_test;
516 using default_ops::eval_is_zero;
517 if ((m_exponent <= max_exponent) && (m_exponent >= min_exponent))
519 BOOST_ASSERT(eval_bit_test(m_data, bit_count - 1));
523 BOOST_ASSERT(m_exponent > max_exponent);
524 BOOST_ASSERT(m_exponent <= exponent_nan);
525 BOOST_ASSERT(eval_is_zero(m_data));
528 template <class Archive>
529 void serialize(Archive& ar, const unsigned int /*version*/)
531 ar& boost::make_nvp("data", m_data);
532 ar& boost::make_nvp("exponent", m_exponent);
533 ar& boost::make_nvp("sign", m_sign);
541 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class Int>
542 inline void copy_and_round(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, Int& arg, int bits_to_keep = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count)
544 // Precondition: exponent of res must have been set before this function is called
545 // as we may need to adjust it based on how many bits_to_keep in arg are set.
546 using default_ops::eval_bit_test;
547 using default_ops::eval_get_sign;
548 using default_ops::eval_increment;
549 using default_ops::eval_left_shift;
550 using default_ops::eval_lsb;
551 using default_ops::eval_msb;
552 using default_ops::eval_right_shift;
554 // cancellation may have resulted in arg being all zeros:
555 if (eval_get_sign(arg) == 0)
557 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
559 res.bits() = static_cast<limb_type>(0u);
562 int msb = eval_msb(arg);
563 if (static_cast<int>(bits_to_keep) > msb + 1)
565 // Must have had cancellation in subtraction,
566 // or be converting from a narrower type, so shift left:
568 eval_left_shift(res.bits(), bits_to_keep - msb - 1);
569 res.exponent() -= static_cast<Exponent>(bits_to_keep - msb - 1);
571 else if (static_cast<int>(bits_to_keep) < msb + 1)
573 // We have more bits_to_keep than we need, so round as required,
574 // first get the rounding bit:
575 bool roundup = eval_bit_test(arg, msb - bits_to_keep);
576 // Then check for a tie:
577 if (roundup && (msb - bits_to_keep == (int)eval_lsb(arg)))
579 // Ties round towards even:
580 if (!eval_bit_test(arg, msb - bits_to_keep + 1))
583 // Shift off the bits_to_keep we don't need:
584 eval_right_shift(arg, msb - bits_to_keep + 1);
585 res.exponent() += static_cast<Exponent>(msb - bits_to_keep + 1);
591 if (eval_bit_test(arg, bits_to_keep))
593 // This happens very very rairly, all the bits left after
594 // truncation must be 1's and we're rounding up an order of magnitude:
595 eval_right_shift(arg, 1u);
601 // We get here when bits_to_keep is zero but we're rounding up,
602 // as a result we end up with a single digit that is a 1:
606 if (bits_to_keep != cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count)
608 // Normalize result when we're rounding to fewer bits than we can hold, only happens in conversions
609 // to narrower types:
610 eval_left_shift(arg, cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - bits_to_keep);
611 res.exponent() -= static_cast<Exponent>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - bits_to_keep);
619 if (!bits_to_keep && !res.bits().limbs()[0])
621 // We're keeping zero bits and did not round up, so result is zero:
622 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
625 // Result must be normalized:
626 BOOST_ASSERT(((int)eval_msb(res.bits()) == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1));
628 if (res.exponent() > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent)
631 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity;
632 res.bits() = static_cast<limb_type>(0u);
634 else if (res.exponent() < cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent)
637 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
638 res.bits() = static_cast<limb_type>(0u);
642 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
643 inline void do_eval_add(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& b)
645 if (a.exponent() < b.exponent())
648 do_eval_add(res, b, a);
654 using default_ops::eval_add;
655 using default_ops::eval_bit_test;
657 typedef typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type exponent_type;
659 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type dt;
661 // Special cases first:
662 switch (a.exponent())
664 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
671 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
672 if (b.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan)
676 return; // result is still infinite.
677 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
679 return; // result is still a NaN.
681 switch (b.exponent())
683 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
686 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
690 return; // result is infinite.
691 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
693 return; // result is a NaN.
696 BOOST_STATIC_ASSERT(boost::integer_traits<exponent_type>::const_max - cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent);
700 if (a.exponent() > (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + b.exponent())
702 res.exponent() = a.exponent();
706 exponent_type e_diff = a.exponent() - b.exponent();
707 BOOST_ASSERT(e_diff >= 0);
708 eval_left_shift(dt, e_diff);
709 res.exponent() = a.exponent() - e_diff;
710 eval_add(dt, b.bits());
713 copy_and_round(res, dt);
714 res.check_invariants();
719 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
720 inline void do_eval_subtract(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& b)
722 using default_ops::eval_bit_test;
723 using default_ops::eval_decrement;
724 using default_ops::eval_subtract;
726 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type dt;
728 // Special cases first:
729 switch (a.exponent())
731 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
732 if (b.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan)
733 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
738 if (res.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero)
740 else if (res.sign() == s)
744 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
745 if ((b.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan) || (b.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity))
746 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
750 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
752 return; // result is still a NaN.
754 switch (b.exponent())
756 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
759 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
760 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity;
761 res.sign() = !a.sign();
762 res.bits() = static_cast<limb_type>(0u);
763 return; // result is a NaN.
764 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
766 return; // result is still a NaN.
770 if ((a.exponent() > b.exponent()) || ((a.exponent() == b.exponent()) && a.bits().compare(b.bits()) >= 0))
773 if (a.exponent() <= (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + b.exponent())
775 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type e_diff = a.exponent() - b.exponent();
776 eval_left_shift(dt, e_diff);
777 res.exponent() = a.exponent() - e_diff;
778 eval_subtract(dt, b.bits());
780 else if (a.exponent() == (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + b.exponent() + 1)
782 if (eval_lsb(b.bits()) != cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1)
784 eval_left_shift(dt, 1);
786 res.exponent() = a.exponent() - 1;
789 res.exponent() = a.exponent();
792 res.exponent() = a.exponent();
797 if (b.exponent() <= (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + a.exponent())
799 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type e_diff = a.exponent() - b.exponent();
800 eval_left_shift(dt, -e_diff);
801 res.exponent() = b.exponent() + e_diff;
802 eval_subtract(dt, a.bits());
804 else if (b.exponent() == (int)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + a.exponent() + 1)
806 if (eval_lsb(a.bits()) != cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1)
808 eval_left_shift(dt, 1);
810 res.exponent() = b.exponent() - 1;
813 res.exponent() = b.exponent();
816 res.exponent() = b.exponent();
820 copy_and_round(res, dt);
821 if (res.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero)
823 else if (res.sign() != s)
825 res.check_invariants();
828 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
829 inline void eval_add(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& b)
831 if (a.sign() == b.sign())
832 do_eval_add(res, a, b);
834 do_eval_subtract(res, a, b);
837 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
838 inline void eval_add(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a)
840 return eval_add(res, res, a);
843 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
844 inline void eval_subtract(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& b)
846 if (a.sign() != b.sign())
847 do_eval_add(res, a, b);
849 do_eval_subtract(res, a, b);
852 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
853 inline void eval_subtract(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a)
855 return eval_subtract(res, res, a);
858 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
859 inline void eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& b)
861 using default_ops::eval_bit_test;
862 using default_ops::eval_multiply;
864 // Special cases first:
865 switch (a.exponent())
867 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
869 if (b.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan)
871 else if (b.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity)
872 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
875 bool s = a.sign() != b.sign();
881 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
882 switch (b.exponent())
884 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
885 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
887 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
891 bool s = a.sign() != b.sign();
897 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
901 if (b.exponent() > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent)
903 bool s = a.sign() != b.sign();
908 if ((a.exponent() > 0) && (b.exponent() > 0))
910 if (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent + 2 - a.exponent() < b.exponent())
912 // We will certainly overflow:
913 bool s = a.sign() != b.sign();
914 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity;
916 res.bits() = static_cast<limb_type>(0u);
920 if ((a.exponent() < 0) && (b.exponent() < 0))
922 if (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent - 2 - a.exponent() > b.exponent())
924 // We will certainly underflow:
925 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
926 res.sign() = a.sign() != b.sign();
927 res.bits() = static_cast<limb_type>(0u);
932 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type dt;
933 eval_multiply(dt, a.bits(), b.bits());
934 res.exponent() = a.exponent() + b.exponent() - (Exponent)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + 1;
935 copy_and_round(res, dt);
936 res.check_invariants();
937 res.sign() = a.sign() != b.sign();
940 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
941 inline void eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a)
943 eval_multiply(res, res, a);
946 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class U>
947 inline typename enable_if_c<is_unsigned<U>::value>::type eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const U& b)
949 using default_ops::eval_bit_test;
950 using default_ops::eval_multiply;
952 // Special cases first:
953 switch (a.exponent())
955 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
962 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
964 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
968 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
973 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type dt;
974 typedef typename boost::multiprecision::detail::canonical<U, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type>::type canon_ui_type;
975 eval_multiply(dt, a.bits(), static_cast<canon_ui_type>(b));
976 res.exponent() = a.exponent();
977 copy_and_round(res, dt);
978 res.check_invariants();
979 res.sign() = a.sign();
982 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class U>
983 inline typename enable_if_c<is_unsigned<U>::value>::type eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const U& b)
985 eval_multiply(res, res, b);
988 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class S>
989 inline typename enable_if_c<is_signed<S>::value>::type eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, const S& b)
991 typedef typename make_unsigned<S>::type ui_type;
992 eval_multiply(res, a, static_cast<ui_type>(boost::multiprecision::detail::unsigned_abs(b)));
997 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class S>
998 inline typename enable_if_c<is_signed<S>::value>::type eval_multiply(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const S& b)
1000 eval_multiply(res, res, b);
1003 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1004 inline void eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& u, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& v)
1007 #pragma warning(push)
1008 #pragma warning(disable : 6326) // comparison of two constants
1010 using default_ops::eval_bit_test;
1011 using default_ops::eval_get_sign;
1012 using default_ops::eval_increment;
1013 using default_ops::eval_qr;
1014 using default_ops::eval_subtract;
1017 // Special cases first:
1019 switch (u.exponent())
1021 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1023 switch (v.exponent())
1025 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1026 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1027 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1030 bool s = u.sign() != v.sign();
1035 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1037 switch (v.exponent())
1039 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1040 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1041 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1044 bool s = u.sign() != v.sign();
1049 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1050 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1053 switch (v.exponent())
1055 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1057 bool s = u.sign() != v.sign();
1058 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity().backend();
1062 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1063 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
1064 res.bits() = limb_type(0);
1065 res.sign() = u.sign() != v.sign();
1067 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1068 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1072 // We can scale u and v so that both are integers, then perform integer
1073 // division to obtain quotient q and remainder r, such that:
1081 // From this, assuming q has cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count
1082 // bits we only need to determine whether
1083 // r/v is less than, equal to, or greater than 0.5 to determine rounding -
1084 // this we can do with a shift and comparison.
1086 // We can set the exponent and sign of the result up front:
1088 if ((v.exponent() < 0) && (u.exponent() > 0))
1090 // Check for overflow:
1091 if (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent + v.exponent() < u.exponent() - 1)
1093 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity;
1094 res.sign() = u.sign() != v.sign();
1095 res.bits() = static_cast<limb_type>(0u);
1099 else if ((v.exponent() > 0) && (u.exponent() < 0))
1101 // Check for underflow:
1102 if (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent + v.exponent() > u.exponent())
1104 // We will certainly underflow:
1105 res.exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
1106 res.sign() = u.sign() != v.sign();
1107 res.bits() = static_cast<limb_type>(0u);
1111 res.exponent() = u.exponent() - v.exponent() - 1;
1112 res.sign() = u.sign() != v.sign();
1114 // Now get the quotient and remainder:
1116 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type t(u.bits()), t2(v.bits()), q, r;
1117 eval_left_shift(t, cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count);
1118 eval_qr(t, t2, q, r);
1120 // We now have either "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count"
1121 // or "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count+1" significant
1124 static const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT;
1125 if (eval_bit_test(q, cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count))
1128 // OK we have cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count+1 bits,
1129 // so we already have rounding info,
1130 // we just need to changes things if the last bit is 1 and either the
1131 // remainder is non-zero (ie we do not have a tie) or the quotient would
1132 // be odd if it were shifted to the correct number of bits (ie a tiebreak).
1134 BOOST_ASSERT((eval_msb(q) == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count));
1135 if ((q.limbs()[0] & 1u) && (eval_get_sign(r) || (q.limbs()[0] & 2u)))
1143 // We have exactly "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count" bits in q.
1144 // Get rounding info, which we can get by comparing 2r with v.
1145 // We want to call copy_and_round to handle rounding and general cleanup,
1146 // so we'll left shift q and add some fake digits on the end to represent
1147 // how we'll be rounding.
1149 BOOST_ASSERT((eval_msb(q) == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1));
1150 static const unsigned lshift = (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count < limb_bits) ? 2 : limb_bits;
1151 eval_left_shift(q, lshift);
1152 res.exponent() -= lshift;
1153 eval_left_shift(r, 1u);
1154 int c = r.compare(v.bits());
1156 q.limbs()[0] |= static_cast<limb_type>(1u) << (lshift - 1);
1158 q.limbs()[0] |= (static_cast<limb_type>(1u) << (lshift - 1)) + static_cast<limb_type>(1u);
1160 copy_and_round(res, q);
1162 #pragma warning(pop)
1166 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1167 inline void eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1169 eval_divide(res, res, arg);
1172 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class U>
1173 inline typename enable_if_c<is_unsigned<U>::value>::type eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& u, const U& v)
1176 #pragma warning(push)
1177 #pragma warning(disable : 6326) // comparison of two constants
1179 using default_ops::eval_bit_test;
1180 using default_ops::eval_get_sign;
1181 using default_ops::eval_increment;
1182 using default_ops::eval_qr;
1183 using default_ops::eval_subtract;
1186 // Special cases first:
1188 switch (u.exponent())
1190 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1194 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1197 bool s = u.sign() != (v < 0);
1202 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1205 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1206 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1212 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity().backend();
1217 // We can scale u and v so that both are integers, then perform integer
1218 // division to obtain quotient q and remainder r, such that:
1226 // From this, assuming q has "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count" cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count, we only need to determine whether
1227 // r/v is less than, equal to, or greater than 0.5 to determine rounding -
1228 // this we can do with a shift and comparison.
1230 // We can set the exponent and sign of the result up front:
1233 res.exponent() = u.exponent() - static_cast<Exponent>(gb) - static_cast<Exponent>(1);
1234 res.sign() = u.sign();
1236 // Now get the quotient and remainder:
1238 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type t(u.bits()), q, r;
1239 eval_left_shift(t, gb + 1);
1240 eval_qr(t, number<typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type>::canonical_value(v), q, r);
1242 // We now have either "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count" or "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count+1" significant cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count in q.
1244 static const unsigned limb_bits = sizeof(limb_type) * CHAR_BIT;
1245 if (eval_bit_test(q, cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count))
1248 // OK we have cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count+1 cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count, so we already have rounding info,
1249 // we just need to changes things if the last bit is 1 and the
1250 // remainder is non-zero (ie we do not have a tie).
1252 BOOST_ASSERT((eval_msb(q) == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count));
1253 if ((q.limbs()[0] & 1u) && eval_get_sign(r))
1261 // We have exactly "cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count" cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count in q.
1262 // Get rounding info, which we can get by comparing 2r with v.
1263 // We want to call copy_and_round to handle rounding and general cleanup,
1264 // so we'll left shift q and add some fake cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count on the end to represent
1265 // how we'll be rounding.
1267 BOOST_ASSERT((eval_msb(q) == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1));
1268 static const unsigned lshift = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count < limb_bits ? 2 : limb_bits;
1269 eval_left_shift(q, lshift);
1270 res.exponent() -= lshift;
1271 eval_left_shift(r, 1u);
1272 int c = r.compare(number<typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type>::canonical_value(v));
1274 q.limbs()[0] |= static_cast<limb_type>(1u) << (lshift - 1);
1276 q.limbs()[0] |= (static_cast<limb_type>(1u) << (lshift - 1)) + static_cast<limb_type>(1u);
1278 copy_and_round(res, q);
1280 #pragma warning(pop)
1284 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class U>
1285 inline typename enable_if_c<is_unsigned<U>::value>::type eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const U& v)
1287 eval_divide(res, res, v);
1290 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class S>
1291 inline typename enable_if_c<is_signed<S>::value>::type eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& u, const S& v)
1293 typedef typename make_unsigned<S>::type ui_type;
1294 eval_divide(res, u, static_cast<ui_type>(boost::multiprecision::detail::unsigned_abs(v)));
1299 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class S>
1300 inline typename enable_if_c<is_signed<S>::value>::type eval_divide(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const S& v)
1302 eval_divide(res, res, v);
1305 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1306 inline int eval_get_sign(const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1308 return arg.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero ? 0 : arg.sign() ? -1 : 1;
1311 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1312 inline bool eval_is_zero(const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1314 return arg.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
1317 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1318 inline bool eval_eq(const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& a, cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& b)
1320 if (a.exponent() == b.exponent())
1322 if (a.exponent() == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero)
1324 return (a.sign() == b.sign()) && (a.bits().compare(b.bits()) == 0) && (a.exponent() != cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan);
1329 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1330 inline void eval_convert_to(boost::long_long_type* res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1332 switch (arg.exponent())
1334 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1337 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1338 BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1339 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1340 *res = (std::numeric_limits<boost::long_long_type>::max)();
1345 typedef typename mpl::if_c<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type shift_type;
1346 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::rep_type man(arg.bits());
1347 shift_type shift = (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 - arg.exponent();
1348 if (shift > (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1)
1353 if (arg.sign() && (arg.compare((std::numeric_limits<boost::long_long_type>::min)()) <= 0))
1355 *res = (std::numeric_limits<boost::long_long_type>::min)();
1358 else if (!arg.sign() && (arg.compare((std::numeric_limits<boost::long_long_type>::max)()) >= 0))
1360 *res = (std::numeric_limits<boost::long_long_type>::max)();
1366 if (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - shift <= std::numeric_limits<boost::long_long_type>::digits)
1368 // We have more bits in long_long_type than the float, so it's OK to left shift:
1369 eval_convert_to(res, man);
1374 *res = (std::numeric_limits<boost::long_long_type>::max)();
1380 eval_right_shift(man, shift);
1381 eval_convert_to(res, man);
1389 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1390 inline void eval_convert_to(boost::ulong_long_type* res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1392 switch (arg.exponent())
1394 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1397 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1398 BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1399 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1400 *res = (std::numeric_limits<boost::ulong_long_type>::max)();
1403 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::rep_type man(arg.bits());
1404 typedef typename mpl::if_c<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type shift_type;
1405 shift_type shift = (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 - arg.exponent();
1406 if (shift > (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1)
1413 if (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - shift <= std::numeric_limits<boost::ulong_long_type>::digits)
1415 // We have more bits in ulong_long_type than the float, so it's OK to left shift:
1416 eval_convert_to(res, man);
1420 *res = (std::numeric_limits<boost::ulong_long_type>::max)();
1423 eval_right_shift(man, shift);
1424 eval_convert_to(res, man);
1427 template <class Float, unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1428 inline typename boost::enable_if_c<boost::is_float<Float>::value>::type eval_convert_to(Float* res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& original_arg)
1430 typedef cpp_bin_float<std::numeric_limits<Float>::digits, digit_base_2, void, Exponent, MinE, MaxE> conv_type;
1431 typedef typename common_type<typename conv_type::exponent_type, int>::type common_exp_type;
1433 // Special cases first:
1435 switch (original_arg.exponent())
1437 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1439 if (original_arg.sign())
1442 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1443 *res = std::numeric_limits<Float>::quiet_NaN();
1445 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1446 *res = (std::numeric_limits<Float>::infinity)();
1447 if (original_arg.sign())
1452 // Check for super large exponent that must be converted to infinity:
1454 if (original_arg.exponent() > std::numeric_limits<Float>::max_exponent)
1456 *res = std::numeric_limits<Float>::has_infinity ? std::numeric_limits<Float>::infinity() : (std::numeric_limits<Float>::max)();
1457 if (original_arg.sign())
1462 // Figure out how many digits we will have in our result,
1463 // allowing for a possibly denormalized result:
1465 common_exp_type digits_to_round_to = std::numeric_limits<Float>::digits;
1466 if (original_arg.exponent() < std::numeric_limits<Float>::min_exponent - 1)
1468 common_exp_type diff = original_arg.exponent();
1469 diff -= std::numeric_limits<Float>::min_exponent - 1;
1470 digits_to_round_to += diff;
1472 if (digits_to_round_to < 0)
1474 // Result must be zero:
1476 if (original_arg.sign())
1481 // Perform rounding first, then afterwards extract the digits:
1483 cpp_bin_float<std::numeric_limits<Float>::digits, digit_base_2, Allocator, Exponent, MinE, MaxE> arg;
1484 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::rep_type bits(original_arg.bits());
1485 arg.exponent() = original_arg.exponent();
1486 copy_and_round(arg, bits, (int)digits_to_round_to);
1487 common_exp_type e = arg.exponent();
1488 e -= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1;
1489 static const unsigned limbs_needed = std::numeric_limits<Float>::digits / (sizeof(*arg.bits().limbs()) * CHAR_BIT) + (std::numeric_limits<Float>::digits % (sizeof(*arg.bits().limbs()) * CHAR_BIT) ? 1 : 0);
1490 unsigned first_limb_needed = arg.bits().size() - limbs_needed;
1492 e += first_limb_needed * sizeof(*arg.bits().limbs()) * CHAR_BIT;
1493 while (first_limb_needed < arg.bits().size())
1495 *res += std::ldexp(static_cast<Float>(arg.bits().limbs()[first_limb_needed]), static_cast<int>(e));
1496 ++first_limb_needed;
1497 e += sizeof(*arg.bits().limbs()) * CHAR_BIT;
1499 if (original_arg.sign())
1503 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1504 inline void eval_frexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg, Exponent* e)
1506 switch (arg.exponent())
1508 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1509 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1510 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1516 *e = arg.exponent() + 1;
1517 res.exponent() = -1;
1520 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class I>
1521 inline void eval_frexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg, I* pe)
1524 eval_frexp(res, arg, &e);
1525 if ((e > (std::numeric_limits<I>::max)()) || (e < (std::numeric_limits<I>::min)()))
1527 BOOST_THROW_EXCEPTION(std::runtime_error("Exponent was outside of the range of the argument type to frexp."));
1529 *pe = static_cast<I>(e);
1532 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1533 inline void eval_ldexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg, Exponent e)
1535 switch (arg.exponent())
1537 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1538 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1539 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1543 if ((e > 0) && (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent - e < arg.exponent()))
1546 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity().backend();
1547 res.sign() = arg.sign();
1549 else if ((e < 0) && (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent - e > arg.exponent()))
1557 res.exponent() += e;
1561 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class I>
1562 inline typename enable_if_c<is_unsigned<I>::value>::type eval_ldexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg, I e)
1564 typedef typename make_signed<I>::type si_type;
1565 if (e > static_cast<I>((std::numeric_limits<si_type>::max)()))
1566 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity().backend();
1568 eval_ldexp(res, arg, static_cast<si_type>(e));
1571 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class I>
1572 inline typename enable_if_c<is_signed<I>::value>::type eval_ldexp(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg, I e)
1574 if ((e > (std::numeric_limits<Exponent>::max)()) || (e < (std::numeric_limits<Exponent>::min)()))
1576 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity().backend();
1581 eval_ldexp(res, arg, static_cast<Exponent>(e));
1588 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1589 inline void eval_abs(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1595 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1596 inline void eval_fabs(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1602 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1603 inline int eval_fpclassify(const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1605 switch (arg.exponent())
1607 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1609 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1611 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1617 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1618 inline void eval_sqrt(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1620 using default_ops::eval_bit_test;
1621 using default_ops::eval_increment;
1622 using default_ops::eval_integer_sqrt;
1623 switch (arg.exponent())
1625 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1628 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1631 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1634 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1643 res = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
1648 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::double_rep_type t(arg.bits()), r, s;
1649 eval_left_shift(t, arg.exponent() & 1 ? cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count : cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1);
1650 eval_integer_sqrt(s, r, t);
1652 if (!eval_bit_test(s, cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count))
1654 // We have exactly the right number of cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count in the result, round as required:
1655 if (s.compare(r) < 0)
1660 typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type ae = arg.exponent();
1661 res.exponent() = ae / 2;
1662 if ((ae & 1) && (ae < 0))
1664 copy_and_round(res, s);
1667 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1668 inline void eval_floor(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1670 using default_ops::eval_increment;
1671 switch (arg.exponent())
1673 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1676 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1677 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1681 typedef typename mpl::if_c<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type shift_type;
1683 (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - arg.exponent() - 1;
1684 if ((arg.exponent() > (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent) || (shift <= 0))
1686 // Either arg is already an integer, or a special value:
1690 if (shift >= (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count)
1692 res = static_cast<signed_limb_type>(arg.sign() ? -1 : 0);
1695 bool fractional = (shift_type)eval_lsb(arg.bits()) < shift;
1697 eval_right_shift(res.bits(), shift);
1698 if (fractional && res.sign())
1700 eval_increment(res.bits());
1701 if (eval_msb(res.bits()) != cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 - shift)
1703 // Must have extended result by one bit in the increment:
1708 eval_left_shift(res.bits(), shift);
1711 template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1712 inline void eval_ceil(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& res, const cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& arg)
1714 using default_ops::eval_increment;
1715 switch (arg.exponent())
1717 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity:
1720 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero:
1721 case cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan:
1725 typedef typename mpl::if_c<sizeof(typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type) < sizeof(int), int, typename cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type>::type shift_type;
1726 shift_type shift = (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - arg.exponent() - 1;
1727 if ((arg.exponent() > (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent) || (shift <= 0))
1729 // Either arg is already an integer, or a special value:
1733 if (shift >= (shift_type)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count)
1735 bool s = arg.sign(); // takes care of signed zeros
1736 res = static_cast<signed_limb_type>(arg.sign() ? 0 : 1);
1740 bool fractional = (shift_type)eval_lsb(arg.bits()) < shift;
1742 eval_right_shift(res.bits(), shift);
1743 if (fractional && !res.sign())
1745 eval_increment(res.bits());
1746 if (eval_msb(res.bits()) != cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 - shift)
1748 // Must have extended result by one bit in the increment:
1753 eval_left_shift(res.bits(), shift);
1756 template <unsigned D1, backends::digit_base_type B1, class A1, class E1, E1 M1, E1 M2>
1757 int eval_signbit(const cpp_bin_float<D1, B1, A1, E1, M1, M2>& val)
1762 template <unsigned D1, backends::digit_base_type B1, class A1, class E1, E1 M1, E1 M2>
1763 inline std::size_t hash_value(const cpp_bin_float<D1, B1, A1, E1, M1, M2>& val)
1765 std::size_t result = hash_value(val.bits());
1766 boost::hash_combine(result, val.exponent());
1767 boost::hash_combine(result, val.sign());
1771 } // namespace backends
1773 #ifdef BOOST_NO_SFINAE_EXPR
1777 template <unsigned D1, backends::digit_base_type B1, class A1, class E1, E1 M1, E1 M2, unsigned D2, backends::digit_base_type B2, class A2, class E2, E2 M3, E2 M4>
1778 struct is_explicitly_convertible<backends::cpp_bin_float<D1, B1, A1, E1, M1, M2>, backends::cpp_bin_float<D2, B2, A2, E2, M3, M4> > : public mpl::true_
1780 template <class FloatT, unsigned D2, backends::digit_base_type B2, class A2, class E2, E2 M3, E2 M4>
1781 struct is_explicitly_convertible<FloatT, backends::cpp_bin_float<D2, B2, A2, E2, M3, M4> > : public boost::is_floating_point<FloatT>
1784 } // namespace detail
1787 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Exponent, Exponent MinE, Exponent MaxE, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
1788 inline boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates>
1789 copysign BOOST_PREVENT_MACRO_SUBSTITUTION(
1790 const boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates>& a,
1791 const boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates>& b)
1793 boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> res(a);
1794 res.backend().sign() = b.backend().sign();
1798 using backends::cpp_bin_float;
1799 using backends::digit_base_10;
1800 using backends::digit_base_2;
1802 template <unsigned Digits, backends::digit_base_type DigitBase, class Exponent, Exponent MinE, Exponent MaxE, class Allocator>
1803 struct number_category<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > : public boost::mpl::int_<boost::multiprecision::number_kind_floating_point>
1806 template <unsigned Digits, backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
1807 struct expression_template_default<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> >
1809 static const expression_template_option value = is_void<Allocator>::value ? et_off : et_on;
1812 typedef number<backends::cpp_bin_float<50> > cpp_bin_float_50;
1813 typedef number<backends::cpp_bin_float<100> > cpp_bin_float_100;
1815 typedef number<backends::cpp_bin_float<24, backends::digit_base_2, void, boost::int16_t, -126, 127>, et_off> cpp_bin_float_single;
1816 typedef number<backends::cpp_bin_float<53, backends::digit_base_2, void, boost::int16_t, -1022, 1023>, et_off> cpp_bin_float_double;
1817 typedef number<backends::cpp_bin_float<64, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_off> cpp_bin_float_double_extended;
1818 typedef number<backends::cpp_bin_float<113, backends::digit_base_2, void, boost::int16_t, -16382, 16383>, et_off> cpp_bin_float_quad;
1819 typedef number<backends::cpp_bin_float<237, backends::digit_base_2, void, boost::int32_t, -262142, 262143>, et_off> cpp_bin_float_oct;
1821 } // namespace multiprecision
1825 using boost::multiprecision::copysign;
1826 using boost::multiprecision::signbit;
1830 } // namespace boost
1832 #include <boost/multiprecision/cpp_bin_float/io.hpp>
1833 #include <boost/multiprecision/cpp_bin_float/transcendental.hpp>
1838 // numeric_limits [partial] specializations for the types declared in this header:
1840 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
1841 class numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >
1843 typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> number_type;
1846 BOOST_STATIC_CONSTEXPR bool is_specialized = true;
1847 static number_type(min)()
1849 initializer.do_nothing();
1850 static std::pair<bool, number_type> value;
1854 typedef typename boost::mpl::front<typename number_type::backend_type::unsigned_types>::type ui_type;
1855 value.second.backend() = ui_type(1u);
1856 value.second.backend().exponent() = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
1858 return value.second;
1860 static number_type(max)()
1862 initializer.do_nothing();
1863 static std::pair<bool, number_type> value;
1867 if (boost::is_void<Allocator>::value)
1868 eval_complement(value.second.backend().bits(), value.second.backend().bits());
1871 // We jump through hoops here using the backend type directly just to keep VC12 happy
1872 // (ie compiler workaround, for very strange compiler bug):
1873 using boost::multiprecision::default_ops::eval_add;
1874 using boost::multiprecision::default_ops::eval_decrement;
1875 using boost::multiprecision::default_ops::eval_left_shift;
1876 typedef typename number_type::backend_type::rep_type int_backend_type;
1877 typedef typename boost::mpl::front<typename int_backend_type::unsigned_types>::type ui_type;
1880 eval_left_shift(i, boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1);
1881 int_backend_type j(i);
1884 value.second.backend().bits() = j;
1886 value.second.backend().exponent() = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent;
1888 return value.second;
1890 BOOST_STATIC_CONSTEXPR number_type lowest()
1894 BOOST_STATIC_CONSTEXPR int digits = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count;
1895 BOOST_STATIC_CONSTEXPR int digits10 = (digits - 1) * 301 / 1000;
1896 // Is this really correct???
1897 BOOST_STATIC_CONSTEXPR int max_digits10 = (digits * 301 / 1000) + 3;
1898 BOOST_STATIC_CONSTEXPR bool is_signed = true;
1899 BOOST_STATIC_CONSTEXPR bool is_integer = false;
1900 BOOST_STATIC_CONSTEXPR bool is_exact = false;
1901 BOOST_STATIC_CONSTEXPR int radix = 2;
1902 static number_type epsilon()
1904 initializer.do_nothing();
1905 static std::pair<bool, number_type> value;
1908 // We jump through hoops here just to keep VC12 happy (ie compiler workaround, for very strange compiler bug):
1909 typedef typename boost::mpl::front<typename number_type::backend_type::unsigned_types>::type ui_type;
1911 value.second.backend() = ui_type(1u);
1912 value.second = ldexp(value.second, 1 - (int)digits);
1914 return value.second;
1916 // What value should this be????
1917 static number_type round_error()
1920 initializer.do_nothing();
1921 static std::pair<bool, number_type> value;
1925 // We jump through hoops here just to keep VC12 happy (ie compiler workaround, for very strange compiler bug):
1926 typedef typename boost::mpl::front<typename number_type::backend_type::unsigned_types>::type ui_type;
1927 value.second.backend() = ui_type(1u);
1928 value.second = ldexp(value.second, -1);
1930 return value.second;
1932 BOOST_STATIC_CONSTEXPR typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type min_exponent = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
1933 BOOST_STATIC_CONSTEXPR typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type min_exponent10 = (min_exponent / 1000) * 301L;
1934 BOOST_STATIC_CONSTEXPR typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type max_exponent = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent;
1935 BOOST_STATIC_CONSTEXPR typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type max_exponent10 = (max_exponent / 1000) * 301L;
1936 BOOST_STATIC_CONSTEXPR bool has_infinity = true;
1937 BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
1938 BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
1939 BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
1940 BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
1941 static number_type infinity()
1943 initializer.do_nothing();
1944 static std::pair<bool, number_type> value;
1948 value.second.backend().exponent() = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity;
1950 return value.second;
1952 static number_type quiet_NaN()
1954 initializer.do_nothing();
1955 static std::pair<bool, number_type> value;
1959 value.second.backend().exponent() = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_nan;
1961 return value.second;
1963 BOOST_STATIC_CONSTEXPR number_type signaling_NaN()
1965 return number_type(0);
1967 BOOST_STATIC_CONSTEXPR number_type denorm_min() { return number_type(0); }
1968 BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
1969 BOOST_STATIC_CONSTEXPR bool is_bounded = true;
1970 BOOST_STATIC_CONSTEXPR bool is_modulo = false;
1971 BOOST_STATIC_CONSTEXPR bool traps = true;
1972 BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
1973 BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
1976 struct data_initializer
1980 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::epsilon();
1981 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::round_error();
1982 (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::min)();
1983 (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::max)();
1984 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity();
1985 std::numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN();
1987 void do_nothing() const {}
1989 static const data_initializer initializer;
1992 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
1993 const typename numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::data_initializer numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::initializer;
1995 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
1997 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
1998 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::digits;
1999 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2000 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::digits10;
2001 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2002 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::max_digits10;
2003 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2004 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::is_signed;
2005 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2006 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::is_integer;
2007 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2008 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::is_exact;
2009 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2010 BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::radix;
2011 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2012 BOOST_CONSTEXPR_OR_CONST typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::min_exponent;
2013 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2014 BOOST_CONSTEXPR_OR_CONST typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::min_exponent10;
2015 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2016 BOOST_CONSTEXPR_OR_CONST typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::max_exponent;
2017 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2018 BOOST_CONSTEXPR_OR_CONST typename boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_type numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::max_exponent10;
2019 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2020 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::has_infinity;
2021 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2022 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::has_quiet_NaN;
2023 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2024 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::has_signaling_NaN;
2025 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2026 BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::has_denorm;
2027 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2028 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::has_denorm_loss;
2029 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2030 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::is_iec559;
2031 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2032 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::is_bounded;
2033 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2034 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::is_modulo;
2035 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2036 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::traps;
2037 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2038 BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::tinyness_before;
2039 template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, boost::multiprecision::expression_template_option ExpressionTemplates>
2040 BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, ExpressionTemplates> >::round_style;