Hello. Not sure if i’m writing to a correct category, those, who are moderating the forum, please feel free to move this topic to where it’s appropriate.
I want to discuss Java rules used to check the floating point operations. My case is: when i use direct comparison
true, both snippets are doing the same thing – trying to avoid division by zero, more or less effectively. but different comparison implementations are triggering different rules, so i guess at least one of them needs to be enhanced…
to be more clear, i’ll edit the second snippet with an additional check
I looked at the example that you provided, but could not reproduce S3518. Are you sure that the condition is correct? dValue < 0.00001 || dValue > -0.00001 looks like a condition that is always false, maybe you meant dValue < 0.00001 && dValue > -0.00001?
Hello, Tomasz. I think, that it actually doesn’t matter if it’s “and” or “or”, neither of them guarantee that dValue won’t be zero. Could it be a SonarQube for IDE issue to trigger a rule violation?
Could you please share a complete method that reproduces the issue? The problem appears similar to what’s described in the following ticket, but I am not certain if it is the same: JAVASE-20.