Skip to content

Commit

Permalink
[Bugfix] handle array of zero values (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcutler authored Aug 15, 2020
1 parent fd4cab8 commit 8c2b7ab
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const std::string GradeColor(const std::string &grade) {
// ==========================================================

float compute_average(const std::vector<float> &vals) {
if (vals.size() == 0) return 0;
assert (vals.size() > 0);
float total = 0;
for (std::size_t i = 0; i < vals.size(); i++) {
Expand All @@ -82,6 +83,7 @@ float compute_average(const std::vector<float> &vals) {


float compute_stddev(const std::vector<float> &vals, float average) {
if (vals.size() == 0) return 0;
assert (vals.size() > 0);
float total = 0;
for (std::size_t i = 0; i < vals.size(); i++) {
Expand Down

0 comments on commit 8c2b7ab

Please sign in to comment.