JSONReporter: RoundDouble(): use std::lround() to round double to int

From clang-tidy bugprone-incorrect-roundings check: > casting (double + 0.5) to integer leads to incorrect rounding; consider using lround (#include <cmath>) instead
parent cc7f50e1
...@@ -92,7 +92,7 @@ std::string FormatKV(std::string const& key, double value) { ...@@ -92,7 +92,7 @@ std::string FormatKV(std::string const& key, double value) {
return ss.str(); return ss.str();
} }
int64_t RoundDouble(double v) { return static_cast<int64_t>(v + 0.5); } int64_t RoundDouble(double v) { return std::lround(v); }
} // end namespace } // end namespace
......
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