diff options
| author | Sven Fischer | 2024-05-23 16:49:57 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2024-10-14 21:37:35 +0200 |
| commit | 0b2af562710d1bac7fd32ca3f05bf1d713bb97e4 (patch) | |
| tree | c3dd2afbc4d83e4476dcb8cdb25ddae6e89788bf /src/catch2/benchmark | |
| parent | 69d62abc9a48033177b99ae79c13a6f1b280e94c (diff) | |
| download | catch3-0b2af562710d1bac7fd32ca3f05bf1d713bb97e4.tar.gz | |
Explicitly cast values of different types
In case the warning -Werror=conversion is active with GCC, the warnings
about "conversion from A to B may change value" lead to a compilation
error. This explicitly convert the values to address these warnings.
Diffstat (limited to 'src/catch2/benchmark')
| -rw-r--r-- | src/catch2/benchmark/detail/catch_stats.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index e6de359c..2a5a2e03 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -178,7 +178,7 @@ namespace Catch { double diff = b - m; return a + diff * diff; } ) / - ( last - first ); + static_cast<double>( last - first ); return std::sqrt( variance ); } @@ -213,7 +213,7 @@ namespace Catch { double* first, double* last ) { auto count = last - first; - double idx = (count - 1) * k / static_cast<double>(q); + double idx = static_cast<double>((count - 1) * k) / static_cast<double>(q); int j = static_cast<int>(idx); double g = idx - j; std::nth_element(first, first + j, last); @@ -316,10 +316,10 @@ namespace Catch { double accel = sum_cubes / ( 6 * std::pow( sum_squares, 1.5 ) ); long n = static_cast<long>( resample.size() ); - double prob_n = + double prob_n = static_cast<double>( std::count_if( resample.begin(), resample.end(), - [point]( double x ) { return x < point; } ) / + [point]( double x ) { return x < point; } )) / static_cast<double>( n ); // degenerate case with uniform samples if ( Catch::Detail::directCompare( prob_n, 0. ) ) { |