Refactor exact-zero guards and update mathematical notations across multiple classes to enhance clarity and prevent division by zero errors.

This commit is contained in:
Miha Kralj
2026-02-16 22:30:30 -08:00
parent b63b9730e1
commit fa56e2b76d
10 changed files with 38 additions and 54 deletions
+2 -4
View File
@@ -81,8 +81,7 @@ public sealed class Rocp : AbstractBase
else
{
double past = _buffer[0];
// skipcq: CS-R1077 - Exact-zero guard: IEEE 754 div-by-zero produces Infinity; any nonzero denominator is valid
result = past != 0 ? 100.0 * (value - past) / past : 0.0;
result = past != 0 ? 100.0 * (value - past) / past : 0.0; // skipcq: CS-R1077 - Exact-zero IEEE 754 div guard
}
Last = new TValue(input.Time, result);
@@ -151,8 +150,7 @@ public sealed class Rocp : AbstractBase
else
{
double past = source[i - period];
// skipcq: CS-R1077 - Exact-zero guard: IEEE 754 div-by-zero produces Infinity; any nonzero denominator is valid
output[i] = past != 0 ? 100.0 * (source[i] - past) / past : 0.0;
output[i] = past != 0 ? 100.0 * (source[i] - past) / past : 0.0; // skipcq: CS-R1077 - Exact-zero IEEE 754 div guard
}
}
}