<!--
{
  "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/AdditiveArithmetic",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s18AdditiveArithmeticP"
  },
  "title" : "AdditiveArithmetic"
}
-->

# AdditiveArithmetic

A type with values that support addition and subtraction.

```
protocol AdditiveArithmetic : Equatable
```

## Overview

The `AdditiveArithmetic` protocol provides a suitable basis for additive
arithmetic on scalar values, such as integers and floating-point numbers,
or vectors. You can write generic methods that operate on any numeric type
in the standard library by using the `AdditiveArithmetic` protocol as a
generic constraint.

The following code declares a method that calculates the total of any
sequence with `AdditiveArithmetic` elements.

```
extension Sequence where Element: AdditiveArithmetic {
    func sum() -> Element {
        return reduce(.zero, +)
    }
}
```

The `sum()` method is now available on any sequence with values that
conform to `AdditiveArithmetic`, whether it is an array of `Double` or a
range of `Int`.

```
let arraySum = [1.1, 2.2, 3.3, 4.4, 5.5].sum()
// arraySum == 16.5

let rangeSum = (1..<10).sum()
// rangeSum == 45
```

# Conforming to the AdditiveArithmetic Protocol

To add `AdditiveArithmetic` protocol conformance to your own custom type,
implement the required operators, and provide a static `zero` property.

## Relationships

### Inherited By

[`BinaryFloatingPoint`](/documentation/Swift/BinaryFloatingPoint)

[`FixedWidthInteger`](/documentation/Swift/FixedWidthInteger)

[`BinaryInteger`](/documentation/Swift/BinaryInteger)

[`SignedInteger`](/documentation/Swift/SignedInteger)

[`SignedNumeric`](/documentation/Swift/SignedNumeric)

[`FloatingPoint`](/documentation/Swift/FloatingPoint)

[`DurationProtocol`](/documentation/Swift/DurationProtocol)

[`UnsignedInteger`](/documentation/Swift/UnsignedInteger)

[`Numeric`](/documentation/Swift/Numeric)

### Conforming Types

[`Double`](/documentation/Swift/Double)

[`Float`](/documentation/Swift/Float)

[`Duration`](/documentation/Swift/Duration)

[`UInt128`](/documentation/Swift/UInt128)

[`UInt16`](/documentation/Swift/UInt16)

[`UInt64`](/documentation/Swift/UInt64)

[`Int`](/documentation/Swift/Int)

[`Int32`](/documentation/Swift/Int32)

[`Int8`](/documentation/Swift/Int8)

[`Int16`](/documentation/Swift/Int16)

[`UInt32`](/documentation/Swift/UInt32)

[`Float80`](/documentation/Swift/Float80)

[`Int64`](/documentation/Swift/Int64)

[`Float16`](/documentation/Swift/Float16)

[`UInt8`](/documentation/Swift/UInt8)

[`UInt`](/documentation/Swift/UInt)

[`Int128`](/documentation/Swift/Int128)

### Inherits From

[`Equatable`](/documentation/Swift/Equatable)

---

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)