From 5a06f4788bbf993a52e5b46b842fa7b14f5798b9 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sun, 9 Feb 2025 05:32:05 +0000 Subject: [PATCH] Return NaN instead of 0 when dividing by 0 --- internal/glance/widget-custom-api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/glance/widget-custom-api.go b/internal/glance/widget-custom-api.go index 4c029f6..04211c6 100644 --- a/internal/glance/widget-custom-api.go +++ b/internal/glance/widget-custom-api.go @@ -8,6 +8,7 @@ import ( "html/template" "io" "log/slog" + "math" "net/http" "time" @@ -191,7 +192,7 @@ var customAPITemplateFuncs = func() template.FuncMap { }, "div": func(a, b float64) float64 { if b == 0 { - return 0 + return math.NaN() } return a / b