# no-compare-neg-zero

> Disallow comparing against `-0`

`0` and `-0` compare as equal, so `x === -0` is also `true` when `x` is `0`. The minus sign has no effect.

To tell the two apart, use `Object.is(x, -0)`. Otherwise compare with `0`.

This rule is on by default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

On by default as an error. To turn it off:

```toml bunfig.toml
[lint.rules]
"no-compare-neg-zero" = "off" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
if (offset === -0) {
  flipDirection();
}
```

Not reported:

{/* good */}
```js
if (Object.is(offset, -0)) {
  flipDirection();
}

if (offset === 0) {
  stop();
}
```

`<`, `<=`, `>` and `>=` are reported too:

{/* bad */}
```js
const isForward = speed >= -0;
```
