---
title: AdditiveArithmetic
framework: swift
role: symbol
role_heading: Protocol
path: swift/additivearithmetic
---

# AdditiveArithmetic

A type with values that support addition and subtraction.

## Declaration

```swift
protocol AdditiveArithmetic : Equatable
```

## Overview

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.

## Topics

### Operators

- [+(_:)](swift/additivearithmetic/+(_:).md)
- [+(_:_:)](swift/additivearithmetic/+(_:_:).md)
- [+=(_:_:)](swift/additivearithmetic/+=(_:_:).md)
- [-(_:_:)](swift/additivearithmetic/-(_:_:).md)
- [-=(_:_:)](swift/additivearithmetic/-=(_:_:).md)

### Type Properties

- [zero](swift/additivearithmetic/zero.md)

## Relationships

### Inherits From

- [Equatable](swift/equatable.md)

### Inherited By

- [BinaryFloatingPoint](swift/binaryfloatingpoint.md)
- [BinaryInteger](swift/binaryinteger.md)
- [DurationProtocol](swift/durationprotocol.md)
- [FixedWidthInteger](swift/fixedwidthinteger.md)
- [FloatingPoint](swift/floatingpoint.md)
- [Numeric](swift/numeric.md)
- [SignedInteger](swift/signedinteger.md)
- [SignedNumeric](swift/signednumeric.md)
- [UnsignedInteger](swift/unsignedinteger.md)

### Conforming Types

- [Double](swift/double.md)
- [Duration](swift/duration.md)
- [Float](swift/float.md)
- [Float16](swift/float16.md)
- [Float80](swift/float80.md)
- [Int](swift/int.md)
- [Int128](swift/int128.md)
- [Int16](swift/int16.md)
- [Int32](swift/int32.md)
- [Int64](swift/int64.md)
- [Int8](swift/int8.md)
- [UInt](swift/uint.md)
- [UInt128](swift/uint128.md)
- [UInt16](swift/uint16.md)
- [UInt32](swift/uint32.md)
- [UInt64](swift/uint64.md)
- [UInt8](swift/uint8.md)

## See Also

### Basic Arithmetic

- [Numeric](swift/numeric.md)
- [SignedNumeric](swift/signednumeric.md)
- [Strideable](swift/strideable.md)
