# no-negated-float-comparison

Disallow negated floating-point ordering comparisons that accept NaN

`!(left < right)` evaluates to `true` when either operand is NaN because every ordering comparison with NaN evaluates to `false`.
Instead, you SHOULD handle NaN explicitly and write the intended positive comparison, such as `!left.isNaN() && !right.isNaN() && left >= right`.

- Category: correctness
- Level: warning
- Fix: none
- Scope: module

## Reported

```ds title="main.ds"
function isAtLeast(left: float64, right: float64): boolean {
    return !(left < right);
}
```

## Accepted

```ds title="main.ds"
function isAtLeast(left: float64, right: float64): boolean {
    return !left.isNaN() && !right.isNaN() && left >= right;
}
```

## Prior art

- [Clippy · neg_cmp_op_on_partial_ord](https://rust-lang.github.io/rust-clippy/master/index.html#neg_cmp_op_on_partial_ord)

[language/linter/src/rules/correctness/no_negated_float_comparison.rs:6](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/correctness/no_negated_float_comparison.rs#L6)
