Skip to content

Commit f0e3e4d

Browse files
committed
Add 128-bit framework
1 parent a6ebf50 commit f0e3e4d

File tree

1 file changed

+18
-2
lines changed
  • include/boost/decimal/detail/cmath

1 file changed

+18
-2
lines changed

include/boost/decimal/detail/cmath/fma.hpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ constexpr auto d64_fma_impl(T x, T y, T z) noexcept -> T
134134
abs_lhs_bigger);
135135
}
136136

137+
template <bool, BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
138+
constexpr auto d128_fma_impl(T x, T y, T z) noexcept -> T
139+
{
140+
return x * y + z;
141+
}
142+
137143
#ifdef _MSC_VER
138144
#pragma warning(pop)
139145
#endif
@@ -158,6 +164,16 @@ constexpr auto unchecked_fma(decimal64_fast x, decimal64_fast y, decimal64_fast
158164
return detail::d64_fma_impl<false>(x, y, z);
159165
}
160166

167+
constexpr auto unchecked_fma(decimal128 x, decimal128 y, decimal128 z) noexcept -> decimal128
168+
{
169+
return detail::d128_fma_impl<false>(x, y, z);
170+
}
171+
172+
constexpr auto unchecked_fma(decimal128_fast x, decimal128_fast y, decimal128_fast z) noexcept -> decimal128_fast
173+
{
174+
return detail::d128_fma_impl<false>(x, y, z);
175+
}
176+
161177
} // Namespace detail
162178

163179
BOOST_DECIMAL_EXPORT constexpr auto fma(decimal32 x, decimal32 y, decimal32 z) noexcept -> decimal32
@@ -172,7 +188,7 @@ BOOST_DECIMAL_EXPORT constexpr auto fma(decimal64 x, decimal64 y, decimal64 z) n
172188

173189
BOOST_DECIMAL_EXPORT constexpr auto fma(decimal128 x, decimal128 y, decimal128 z) noexcept -> decimal128
174190
{
175-
return x * y + z;
191+
return detail::d128_fma_impl<true>(x, y, z);
176192
}
177193

178194
BOOST_DECIMAL_EXPORT constexpr auto fma(decimal32_fast x, decimal32_fast y, decimal32_fast z) noexcept -> decimal32_fast
@@ -187,7 +203,7 @@ BOOST_DECIMAL_EXPORT constexpr auto fma(decimal64_fast x, decimal64_fast y, deci
187203

188204
BOOST_DECIMAL_EXPORT constexpr auto fma(decimal128_fast x, decimal128_fast y, decimal128_fast z) noexcept -> decimal128_fast
189205
{
190-
return x * y + z;
206+
return detail::d128_fma_impl<true>(x, y, z);
191207
}
192208

193209
} //namespace decimal

0 commit comments

Comments
 (0)