---
title: Numeric
framework: swift
role: symbol
role_heading: Protocol
path: swift/numeric
---

# Numeric

A type with values that support multiplication.

## Declaration

```swift
protocol Numeric : AdditiveArithmetic, ExpressibleByIntegerLiteral
```

## Overview

Overview The Numeric protocol provides a suitable basis for arithmetic on scalar values, such as integers and floating-point numbers. You can write generic methods that operate on any numeric type in the standard library by using the Numeric protocol as a generic constraint. The following example extends Sequence with a method that returns an array with the sequence’s values multiplied by two. extension Sequence where Element: Numeric {     func doublingAll() -> [Element] {         return map { $0 * 2 }     } } With this extension, any sequence with elements that conform to Numeric has the doublingAll() method. For example, you can double the elements of an array of doubles or a range of integers: let observations = [1.5, 2.0, 3.25, 4.875, 5.5] let doubledObservations = observations.doublingAll() // doubledObservations == [3.0, 4.0, 6.5, 9.75, 11.0]

let integers = 0..<8 let doubledIntegers = integers.doublingAll() // doubledIntegers == [0, 2, 4, 6, 8, 10, 12, 14] Conforming to the Numeric Protocol To add Numeric protocol conformance to your own custom type, implement the required initializer and operators, and provide a magnitude property using a type that can represent the magnitude of any value of your custom type.

## Topics

### Operators

- [*(_:_:)](swift/numeric/*(_:_:).md)
- [*=(_:_:)](swift/numeric/*=(_:_:).md)

### Associated Types

- [Magnitude](swift/numeric/magnitude-swift.associatedtype.md)

### Initializers

- [init(exactly:)](swift/numeric/init(exactly:).md)

### Instance Properties

- [magnitude](swift/numeric/magnitude-1v49u.md)

## Relationships

### Inherits From

- [AdditiveArithmetic](swift/additivearithmetic.md)
- [Equatable](swift/equatable.md)
- [ExpressibleByIntegerLiteral](swift/expressiblebyintegerliteral.md)

### Inherited By

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

### Conforming Types

- [Double](swift/double.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

- [AdditiveArithmetic](swift/additivearithmetic.md)
- [SignedNumeric](swift/signednumeric.md)
- [Strideable](swift/strideable.md)
