Hi,
Sometimes I need to divide two floating point numbers. To avoid a DivideByZeroException, one needs to check that the denominator is zero. However, that triggers the rule S1244.
I don't want to disable that rule because certainly comparing against a single value is usually wrong, and I want to be reminded of that. However, 0 is special in two regards:
1. It is an additive identity (x + 0 = x)
2. It is special for multiplication (x*0 =0)
3. It cannot be used for division as denominator (x/0 = undefined).
Note that values near zero do not have those properties. Therefore, I think that comparing with zero is not (almost) always an error and should not be flagged as such for this checker.
The questions are then two:
- would it make sense to change this rule to not warn when comparing against zero?
- is it possible to disable this rule only for this case?
Saludos