summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stats.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/stats.h b/stats.h
index fdedf27..5b9a313 100644
--- a/stats.h
+++ b/stats.h
@@ -75,6 +75,9 @@ static inline void minmax_to_be(struct minmax *mm)
static inline double minmax_avg(struct minmax *mm)
{
+ if (!mm->num)
+ return 0;
+
return (mm->sum / (double)mm->num);
}
@@ -82,6 +85,9 @@ static inline double minmax_var(struct minmax *mm)
{
double num = (double)mm->num;
+ if (!mm->num)
+ return 0;
+
return ((mm->sos - ((mm->sum * mm->sum) / num)) / num);
}