# no-compare-neg-zero

Disallow comparisons with negative zero

Equality and ordering comparisons produce the same result for negative and positive zero, so a comparison against negative zero cannot test its sign.
Instead, you SHOULD compare with zero and call `.isSignNegative()` when the sign matters.

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

## Reported

```ds title="main.ds"
function isNegativeZero(value: float64): boolean {
    return value === -0.0;
}
```

## Accepted

```ds title="main.ds"
function isNegativeZero(value: float64): boolean {
    return value === 0.0 && value.isSignNegative();
}
```

## Prior art

- [ESLint · no-compare-neg-zero](https://eslint.org/docs/latest/rules/no-compare-neg-zero)

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