mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
return zero on mov_avg compute if no samples
This commit is contained in:
parent
35bf56663f
commit
826086951e
@ -213,8 +213,13 @@ function util.mov_avg(length)
|
||||
---@nodiscard
|
||||
---@return number average
|
||||
function public.compute()
|
||||
if #data == 0 then return 0 end
|
||||
|
||||
local sum = 0
|
||||
for i = 1, #data do sum = sum + data[i] end
|
||||
for i = 1, #data do
|
||||
sum = sum + data[i]
|
||||
end
|
||||
|
||||
return sum / #data
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user