Skip to content

Commit 87c5e18

Browse files
committed
output: fixed divide by 0 in some cases
1 parent fac2419 commit 87c5e18

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

output/table.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ func (t *Table) Render() string {
108108
}
109109
}
110110
for x := range average {
111-
average[x] = average[x] / count[x]
111+
if count[x] > 0 {
112+
average[x] = average[x] / count[x]
113+
}
112114
}
113115
variance := make([]int, t.columnsCount)
114116
for _, row := range t.rows {
@@ -122,7 +124,9 @@ func (t *Table) Render() string {
122124
}
123125
}
124126
for x := range variance {
125-
variance[x] = int(math.Sqrt(float64(variance[x] / count[x])))
127+
if count[x] > 0 {
128+
variance[x] = int(math.Sqrt(float64(variance[x] / count[x])))
129+
}
126130
}
127131

128132
res := ""

0 commit comments

Comments
 (0)