Floating values are compared for exact equality
What it finds
if (a == b) with double operands: results of floating arithmetic carry rounding errors, so values that should be equal often differ in the last bit. A comparison within a tolerance says what is meant. A comparison with a literal zero, which is exact, is left alone.
From the rule's source, floating_equality.rs.
int same(double a, double b, int i){ if (a == b)tx0 reports: floating values are compared for exact equality return 1; return a != 0.0 && i == 3;} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:floating-equality" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/c:floating-equality] reason="..."tx0 explain tx0/c:floating-equality shows the same in the terminal. Found a false positive? Report it.