diff --git a/include/boost/math/special_functions/next.hpp b/include/boost/math/special_functions/next.hpp index 40134b4e4..0e2e121e7 100644 --- a/include/boost/math/special_functions/next.hpp +++ b/include/boost/math/special_functions/next.hpp @@ -32,7 +32,7 @@ inline T get_smallest_value(mpl::true_ const&) // when using the SSE2 registers in DAZ or FTZ mode. // static const T m = std::numeric_limits::denorm_min(); - return (0 == m) ? tools::min_value() : m; + return ((tools::min_value() - m) == tools::min_value()) ? tools::min_value() : m; } template @@ -52,7 +52,7 @@ inline T get_smallest_value() } // -// Returns the smallest value that won't generate denorms when +// Returns the smallest value that won't generate denorms when // we calculate the value of the least-significant-bit: // template @@ -123,7 +123,7 @@ T float_next(const T& val, const Policy& pol) if((fpclass != FP_SUBNORMAL) && (fpclass != FP_ZERO) && (fabs(val) < detail::get_min_shift_value()) && (val != -tools::min_value())) { // - // Special case: if the value of the least significant bit is a denorm, and the result + // Special case: if the value of the least significant bit is a denorm, and the result // would not be a denorm, then shift the input, increment, and shift back. // This avoids issues with the Intel SSE2 registers when the FTZ or DAZ flags are set. // @@ -194,7 +194,7 @@ T float_prior(const T& val, const Policy& pol) if((fpclass != FP_SUBNORMAL) && (fpclass != FP_ZERO) && (fabs(val) < detail::get_min_shift_value()) && (val != tools::min_value())) { // - // Special case: if the value of the least significant bit is a denorm, and the result + // Special case: if the value of the least significant bit is a denorm, and the result // would not be a denorm, then shift the input, increment, and shift back. // This avoids issues with the Intel SSE2 registers when the FTZ or DAZ flags are set. // @@ -310,7 +310,7 @@ T float_distance(const T& a, const T& b, const Policy& pol) result = float_distance(upper, b); } // - // Use compensated double-double addition to avoid rounding + // Use compensated double-double addition to avoid rounding // errors in the subtraction: // T mb, x, y, z; @@ -384,7 +384,7 @@ T float_advance(T val, int distance, const Policy& pol) if(fabs(val) < detail::get_min_shift_value()) { // - // Special case: if the value of the least significant bit is a denorm, + // Special case: if the value of the least significant bit is a denorm, // implement in terms of float_next/float_prior. // This avoids issues with the Intel SSE2 registers when the FTZ or DAZ flags are set. // @@ -411,7 +411,7 @@ T float_advance(T val, int distance, const Policy& pol) { distance -= itrunc(limit_distance); val = limit; - if(distance < 0) + if(distance < 0) { limit /= 2; expon--;