sal/rtl/math.cxx | 61 +------------------------------------------------------ 1 file changed, 2 insertions(+), 59 deletions(-)
New commits: commit 5ce68783148aa77d77086aac220fabdfa211429d Author: Eike Rathke <er...@redhat.com> Date: Sun Oct 25 16:04:50 2015 +0100 replace implementation of rtl_math_expm1() and rtl_math_log1p() ... with ::std::expm1() and ::std::log1p() of C++11 Change-Id: I0d119958152ea372c136d28705686b44b39015bf Reviewed-on: https://gerrit.libreoffice.org/19588 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx index 5a624e1..10faec3 100644 --- a/sal/rtl/math.cxx +++ b/sal/rtl/math.cxx @@ -971,69 +971,12 @@ double SAL_CALL rtl_math_approxValue( double fValue ) SAL_THROW_EXTERN_C() double SAL_CALL rtl_math_expm1( double fValue ) SAL_THROW_EXTERN_C() { - // See http://en.cppreference.com/w/cpp/numeric/math/expm1 - - if (fValue == 0.0) - return fValue; - - if (!::rtl::math::isFinite(fValue)) - { - if (::rtl::math::isInf(fValue)) - { - if (::rtl::math::isSignBitSet(fValue)) - return -1.0; - else - return fValue; - } - // It is a NaN. - return fValue; - } - - double fe = exp( fValue ); - if (fe == 1.0) - return fValue; - if (fe-1.0 == -1.0) - return -1.0; - return (fe-1.0) * fValue / log(fe); + return ::std::expm1(fValue); } double SAL_CALL rtl_math_log1p( double fValue ) SAL_THROW_EXTERN_C() { - // See http://en.cppreference.com/w/cpp/numeric/math/log1p - - if (fValue == 0.0) - return fValue; - - if (fValue == -1.0) - { - rtl::math::setInf( &fValue, true); - return fValue; - } - - if (fValue < -1.0) // includes -Inf - { - rtl::math::setNan( &fValue); - return fValue; - } - - if (!::rtl::math::isFinite(fValue)) - { - if (::rtl::math::isInf(fValue)) - return fValue; - // It is a NaN. - return fValue; - } - - // Use volatile because a compiler may be too smart "optimizing" the - // condition such that in certain cases the else path was called even if - // (fp==1.0) was true, where the term (fp-1.0) then resulted in 0.0 and - // hence the entire expression resulted in NaN. - // Happened with g++ 3.4.1 and an input value of 9.87E-18 - volatile double fp = 1.0 + fValue; - if (fp == 1.0) - return fValue; - else - return log(fp) * fValue / (fp-1.0); + return ::std::log1p(fValue); } double SAL_CALL rtl_math_atanh( double fValue ) SAL_THROW_EXTERN_C() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits