Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly improve accuracy of stod in to_floats #10622

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cpp/src/strings/convert/convert_floats.cu
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ __device__ inline double stod(string_view const& d_str)
else if (exp_ten < std::numeric_limits<double>::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<double>(digits) * exp10(static_cast<double>(1 - num_digits));
double const exponent = exp10(static_cast<double>(exp_ten));
return base * exponent;
double const exponent = exp10(static_cast<double>(std::abs(exp_ten)));
double const base = sign * static_cast<double>(digits);
return exp_ten < 0 ? base / exponent : base * exponent;
}

/**
Expand Down