16#include <rtl/math.hxx>
20static double err_pow(
const double& fVal1,
const double& fVal2)
24 assert((math_errhandling & (MATH_ERRNO | MATH_ERREXCEPT)) != 0);
25 std::feclearexcept(FE_ALL_EXCEPT);
27 return pow(fVal1, fVal2);
30double power(
const double& fVal1,
const double& fVal2)
33 if (fVal1 < 0 && fVal2 != 0.0)
35 const double f = 1.0 / fVal2 + ((fVal2 < 0.0) ? -0.5 : 0.5);
44 const sal_Int64
i =
static_cast<sal_Int64
>(f);
45 if (
i % 2 != 0 && rtl::math::approxEqual(1 /
static_cast<double>(
i), fVal2))
56 if ((((math_errhandling & MATH_ERRNO) != 0) && (errno == EDOM || errno == ERANGE))
61 || (((math_errhandling & MATH_ERREXCEPT) != 0)
62 && std::fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW))
64 || !std::isfinite(fPow))
double CreateDoubleError(FormulaError nErr)
constexpr std::enable_if_t< std::is_floating_point_v< F > &&std::is_integral_v< I >, bool > convertsToAtLeast(F value, I min)
constexpr std::enable_if_t< std::is_floating_point_v< F > &&std::is_integral_v< I >, bool > convertsToAtMost(F value, I max)
CAUTION! The following defines must be in the same namespace as the respective type.
double power(const double &fVal1, const double &fVal2)
Return pow(fVal1,fVal2) with error handling.
static double err_pow(const double &fVal1, const double &fVal2)