Skip to content

Commit ec5595f

Browse files
committed
Try alternate addition algo-implementation
1 parent f7a6e26 commit ec5595f

File tree

6 files changed

+121
-414
lines changed

6 files changed

+121
-414
lines changed

include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,7 @@ struct exact_arithmetic
8787
return result;
8888
}
8989

90-
static
91-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
92-
BOOST_MP_CXX14_CONSTEXPR
93-
#else
94-
constexpr
95-
#endif
96-
void sum(float_pair& result, float_type a, float_type b)
90+
static constexpr void sum(float_pair& result, float_type a, float_type b)
9791
{
9892
// Exact addition of two floating point numbers
9993
const float_type a_plus_b = a + b;
@@ -105,13 +99,7 @@ struct exact_arithmetic
10599
result.second = tmp.second;
106100
}
107101

108-
static
109-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
110-
BOOST_MP_CXX14_CONSTEXPR
111-
#else
112-
constexpr
113-
#endif
114-
void normalize(float_pair& result, float_type a, float_type b)
102+
static constexpr void normalize(float_pair& result, float_type a, float_type b)
115103
{
116104
// Converts a pair of floats to standard form.
117105
const float_pair tmp = fast_sum(a, b);
@@ -120,13 +108,7 @@ struct exact_arithmetic
120108
result.second = tmp.second;
121109
}
122110

123-
static
124-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
125-
BOOST_MP_CXX14_CONSTEXPR
126-
#else
127-
constexpr
128-
#endif
129-
float_pair split(const float_type& a)
111+
static constexpr float_pair split(const float_type& a)
130112
{
131113
// Split a floating point number in two (high and low) parts approximating the
132114
// upper-half and lower-half bits of the float
@@ -177,13 +159,7 @@ struct exact_arithmetic
177159
return std::make_pair(hi, lo);
178160
}
179161

180-
static
181-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
182-
BOOST_MP_CXX14_CONSTEXPR
183-
#else
184-
constexpr
185-
#endif
186-
float_pair product(const float_type& a, const float_type& b)
162+
static constexpr float_pair product(const float_type& a, const float_type& b)
187163
{
188164
// Exact product of two floating point numbers
189165
const float_pair a_split = split(a);

include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ namespace detail
2121
{
2222

2323
template <typename Real>
24-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
25-
BOOST_MP_CXX14_CONSTEXPR
26-
#else
27-
constexpr
28-
#endif
29-
Real frexp_zero_impl(Real arg, int* exp)
24+
constexpr Real frexp_zero_impl(Real arg, int* exp)
3025
{
3126
if (exp != nullptr)
3227
{
@@ -37,12 +32,7 @@ Real frexp_zero_impl(Real arg, int* exp)
3732
}
3833

3934
template <typename Real>
40-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
41-
BOOST_MP_CXX14_CONSTEXPR
42-
#else
43-
constexpr
44-
#endif
45-
Real frexp_impl(Real arg, int* expptr)
35+
constexpr Real frexp_impl(Real arg, int* expptr)
4636
{
4737
Real f = arg;
4838

@@ -79,12 +69,7 @@ Real frexp_impl(Real arg, int* expptr)
7969
}
8070

8171
template <typename Real>
82-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
83-
BOOST_MP_CXX14_CONSTEXPR
84-
#else
85-
constexpr
86-
#endif
87-
Real frexp_impl_lt_half(Real arg, int* expptr)
72+
constexpr Real frexp_impl_lt_half(Real arg, int* expptr)
8873
{
8974
Real f = arg;
9075

@@ -123,12 +108,7 @@ Real frexp_impl_lt_half(Real arg, int* expptr)
123108
} // namespace detail
124109

125110
template <typename Real>
126-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
127-
BOOST_MP_CXX14_CONSTEXPR
128-
#else
129-
constexpr
130-
#endif
131-
Real frexp(Real arg, int* expptr)
111+
constexpr Real frexp(Real arg, int* expptr)
132112
{
133113
if ( (arg == Real(0))
134114
|| (arg == Real(-0))

include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_
1818
namespace detail {
1919

2020
template <typename Real>
21-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
22-
BOOST_MP_CXX14_CONSTEXPR
23-
#else
24-
constexpr
25-
#endif
26-
Real ldexp_impl(Real arg, int exp) noexcept
21+
constexpr Real ldexp_impl(Real arg, int exp) noexcept
2722
{
2823
while(exp > 0)
2924
{

include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,27 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_
1717
namespace detail {
1818

1919
template <typename Real>
20-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
21-
BOOST_MP_CXX14_CONSTEXPR
22-
#else
23-
constexpr
24-
#endif
25-
Real sqrt_impl_2(Real x, Real s, Real s2)
20+
constexpr Real sqrt_impl_2(Real x, Real s, Real s2)
2621
{
2722
return !(s < s2) ? s2 : sqrt_impl_2(x, (x / s + s) / 2, s);
2823
}
2924

3025
template <typename Real>
31-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
32-
BOOST_MP_CXX14_CONSTEXPR
33-
#else
34-
constexpr
35-
#endif
36-
Real sqrt_impl_1(Real x, Real s)
26+
constexpr Real sqrt_impl_1(Real x, Real s)
3727
{
3828
return sqrt_impl_2(x, (x / s + s) / 2, s);
3929
}
4030

4131
template <typename Real>
42-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
43-
BOOST_MP_CXX14_CONSTEXPR
44-
#else
45-
constexpr
46-
#endif
47-
Real sqrt_impl(Real x)
32+
constexpr Real sqrt_impl(Real x)
4833
{
4934
return sqrt_impl_1(x, x > 1 ? x : Real(1));
5035
}
5136

5237
} // namespace detail
5338

5439
template <typename Real>
55-
#if (defined(_MSC_VER) && (_MSC_VER <= 1900))
56-
BOOST_MP_CXX14_CONSTEXPR
57-
#else
58-
constexpr
59-
#endif
60-
Real sqrt(Real x)
40+
constexpr Real sqrt(Real x)
6141
{
6242
return cpp_df_qf_detail::ccmath::isnan(x) ? ccmath::numeric_limits<Real>::quiet_NaN() :
6343
cpp_df_qf_detail::ccmath::isinf(x) ? ccmath::numeric_limits<Real>::infinity() :

0 commit comments

Comments
 (0)