Sensor Statistic NaN Fix (#1549)

https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/issues/1537
When a Nan or infinity value is added, the Min/Max function is not working.
This commit is contained in:
sebastian-dev
2025-01-16 15:10:05 +01:00
committed by GitHub
parent 880321f2a7
commit 77f3de2292
+8 -5
View File
@@ -134,11 +134,14 @@ internal class Sensor : ISensor
_currentValue = value;
if (_trackMinMax)
{
if (!Min.HasValue || Min > value)
Min = value;
if (value.HasValue && !float.IsNaN(value.Value) && !float.IsInfinity(value.Value))
{
if (!Min.HasValue || Min > value)
Min = value;
if (!Max.HasValue || Max < value)
Max = value;
if (!Max.HasValue || Max < value)
Max = value;
}
}
}
}
@@ -273,4 +276,4 @@ internal class Sensor : ISensor
_values.Add(new SensorValue(value, time));
}
}
}