Skip to content

Commit

Permalink
Fix type conversion warnings. (#951)
Browse files Browse the repository at this point in the history
* Fix type conversion warnings.

Fixes #949

Tested locally (Linux/clang), but warnings are on MSVC so may differ.

* Drop the ULP so the double test passes
  • Loading branch information
dominichamon committed Apr 6, 2020
1 parent b23d355 commit 0ab2c29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/benchmark_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ class BenchmarkRunner {
if (multiplier <= 1.0) multiplier = 2.0;

// So what seems to be the sufficiently-large iteration count? Round up.
const IterationCount max_next_iters =
std::lround(std::max(multiplier * i.iters, i.iters + 1.0));
const IterationCount max_next_iters = static_cast<IterationCount>(
std::lround(std::max(multiplier * static_cast<double>(i.iters),
static_cast<double>(i.iters) + 1.0)));
// But we do have *some* sanity limits though..
const IterationCount next_iters = std::min(max_next_iters, kMaxIterations);

Expand Down
4 changes: 2 additions & 2 deletions test/statistics_gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ TEST(StatisticsTest, Median) {
TEST(StatisticsTest, StdDev) {
EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({101, 101, 101, 101}), 0.0);
EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({1, 2, 3}), 1.0);
EXPECT_FLOAT_EQ(benchmark::StatisticsStdDev({1.5, 2.4, 3.3, 4.2, 5.1}),
1.42302495);
EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({2.5, 2.4, 3.3, 4.2, 5.1}),
1.151086443322134);
}

} // end namespace

0 comments on commit 0ab2c29

Please sign in to comment.