---
title: "constant-negative-zero"
description: "Detect constant expressions that cannot represent negative zero."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# constant-negative-zero

**Default severity:** `warning`

Go's ideal constants do not preserve a zero sign. Literal forms such as `-0.0`,
`-float64(0)`, and `float32(-0)` therefore produce positive zero at runtime.
Use `math.Copysign` when a true IEEE negative zero is required.

## Bad

```go
negativeZero := -0.0
```

## Good

```go
negativeZero := math.Copysign(0, -1)
```

Source: https://strider.gempir.com/analyzers/constant-negative-zero/index.mdx
