Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / math / special_functions / cbrt.hpp
index 0fc6e07..c34ad39 100644 (file)
@@ -68,7 +68,8 @@ T cbrt_imp(T z, const Policy& pol)
       static_cast<T>(1.2599210498948731647672106072782),   // 2^1/3
       static_cast<T>(1.5874010519681994747517056392723),   // 2^2/3
    };
-
+   if((boost::math::isinf)(z) || (z == 0))
+      return z;
    if(!(boost::math::isfinite)(z))
    {
       return policies::raise_domain_error("boost::math::cbrt<%1%>(%1%)", "Argument to function must be finite but got %1%.", z, pol);
@@ -80,8 +81,6 @@ T cbrt_imp(T z, const Policy& pol)
       z = -z;
       sign = -sign;
    }
-   if(z == 0)
-      return 0;
 
    T guess = frexp(z, &i_exp);
    int original_i_exp = i_exp; // save for later