Fix NaN*10^(-9223372036854775808) glitch
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
MassiveBox 2023-06-23 13:43:03 +02:00
parent 22ed86d6f3
commit 068aae82c3
Signed by: massivebox
GPG key ID: 9B74D3A59181947D

View file

@ -18,7 +18,7 @@ func TemplateDivide(num1, num2 float32) template.HTML {
division := float64(num1 / num2)
powerOfTen := int(math.Floor(math.Log10(division)))
if powerOfTen >= -2 && powerOfTen <= 2 {
if (powerOfTen >= -2 && powerOfTen <= 2) || division == 0 {
// #nosec G203 // We're only printing floats
return template.HTML(strconv.FormatFloat(math.Round(division*100)/100, 'f', -1, 64))
}