Floating values are compared for exact equality

tx0/cpp:floating-equalitystrictwarningmaintainability/designdepth fastsmell

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.

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:

tx0.toml
[rules]
"tx0/cpp: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/cpp:floating-equality] reason="..."

tx0 explain tx0/cpp:floating-equality shows the same in the terminal. Found a false positive? Report it.