Kaydet (Commit) 5f2db274 authored tarafından Eike Rathke's avatar Eike Rathke

implement proper Inf and NaN handling in rtl_math_erf() and rtl_math_erfc()

Change-Id: Ib96d7123a3c483e9a1c78666bf042396510d733f
üst 0d4f4223
...@@ -1143,7 +1143,18 @@ double SAL_CALL rtl_math_erf( double x ) SAL_THROW_EXTERN_C() ...@@ -1143,7 +1143,18 @@ double SAL_CALL rtl_math_erf( double x ) SAL_THROW_EXTERN_C()
// Otherwise we may end up in endless recursion through rtl_math_erfc(). // Otherwise we may end up in endless recursion through rtl_math_erfc().
if (!::rtl::math::isFinite(x)) if (!::rtl::math::isFinite(x))
{
// See http://en.cppreference.com/w/cpp/numeric/math/erf
if (::rtl::math::isInf(x))
{
if (::rtl::math::isSignBitSet(x))
return -1.0;
else
return 1.0;
}
// It is a NaN.
return x; return x;
}
bool bNegative = false; bool bNegative = false;
if ( x < 0.0 ) if ( x < 0.0 )
...@@ -1183,7 +1194,18 @@ double SAL_CALL rtl_math_erfc( double x ) SAL_THROW_EXTERN_C() ...@@ -1183,7 +1194,18 @@ double SAL_CALL rtl_math_erfc( double x ) SAL_THROW_EXTERN_C()
// Otherwise we may end up in endless recursion through rtl_math_erf(). // Otherwise we may end up in endless recursion through rtl_math_erf().
if (!::rtl::math::isFinite(x)) if (!::rtl::math::isFinite(x))
{
// See http://en.cppreference.com/w/cpp/numeric/math/erfc
if (::rtl::math::isInf(x))
{
if (::rtl::math::isSignBitSet(x))
return 2.0;
else
return 0.0;
}
// It is a NaN.
return x; return x;
}
bool bNegative = false; bool bNegative = false;
if ( x < 0.0 ) if ( x < 0.0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment