<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Int/negate()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s13SignedNumericPsE6negateyyF::SYNTHESIZED::s:Si"
  },
  "title" : "negate()"
}
-->

# negate()

Replaces this value with its additive inverse.

```
mutating func negate()
```

## Discussion

The following example uses the `negate()` method to negate the value of
an integer `x`:

```
var x = 21
x.negate()
// x == -21
```

The resulting value must be representable within the value’s type. In
particular, negating a signed, fixed-width integer type’s minimum
results in a value that cannot be represented.

```
var y = Int8.min
y.negate()
// Overflow error
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)