mirror of
https://github.com/google/benchmark.git
synced 2025-02-06 01:00:17 +08:00
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
This commit is contained in:
parent
cc7f50e126
commit
c22c266eaf
@ -92,7 +92,7 @@ std::string FormatKV(std::string const& key, double value) {
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user