diff --git a/cpp/src/strings/convert/convert_floats.cu b/cpp/src/strings/convert/convert_floats.cu index bd54e20a0f0..b8a10a00f5b 100644 --- a/cpp/src/strings/convert/convert_floats.cu +++ b/cpp/src/strings/convert/convert_floats.cu @@ -130,11 +130,11 @@ __device__ inline double stod(string_view const& d_str) else if (exp_ten < std::numeric_limits::min_exponent10) return double{0}; + exp_ten += 1 - num_digits; // exp10() is faster than pow(10.0,exp_ten) - double const base = - sign * static_cast(digits) * exp10(static_cast(1 - num_digits)); - double const exponent = exp10(static_cast(exp_ten)); - return base * exponent; + double const exponent = exp10(static_cast(std::abs(exp_ten))); + double const base = sign * static_cast(digits); + return exp_ten < 0 ? base / exponent : base * exponent; } /**