mirror of
https://gitea.massivebox.net/massivebox/ecodash.git
synced 2025-01-15 21:27:31 +01:00
Fix NaN*10^(-9223372036854775808) glitch
This commit is contained in:
parent
22ed86d6f3
commit
068aae82c3
@ -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))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user