IntegerArithmeticType

protocol IntegerArithmeticType

The common requirements for types that support integer arithmetic.

Inheritance Comparable, Equatable, _Comparable, _IntegerArithmeticType View Protocol Hierarchy →
Import import Swift

Static Methods

static func addWithOverflow(_:_:) Required

Add lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

Declaration

static func addWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool)

Declared In

_IntegerArithmeticType
static func divideWithOverflow(_:_:) Required

Divide lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

Declaration

static func divideWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool)

Declared In

_IntegerArithmeticType
static func multiplyWithOverflow(_:_:) Required

Multiply lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

Declaration

static func multiplyWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool)

Declared In

_IntegerArithmeticType
static func remainderWithOverflow(_:_:) Required

Divide lhs and rhs, returning the remainder and a Bool that is true iff the operation caused an arithmetic overflow.

Declaration

static func remainderWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool)

Declared In

_IntegerArithmeticType
static func subtractWithOverflow(_:_:) Required

Subtract lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

Declaration

static func subtractWithOverflow(lhs: Self, _ rhs: Self) -> (Self, overflow: Bool)

Declared In

_IntegerArithmeticType

Instance Methods

func %(_:rhs:) Required

Divide lhs and rhs, returning the remainder and trapping in case of arithmetic overflow (except in -Ounchecked builds).

Declaration

func %(lhs: Self, rhs: Self) -> Self
func *(_:rhs:) Required

Multiply lhs and rhs, returning a result and trapping in case of arithmetic overflow (except in -Ounchecked builds).

Declaration

func *(lhs: Self, rhs: Self) -> Self
func +(_:rhs:) Required

Add lhs and rhs, returning a result and trapping in case of arithmetic overflow (except in -Ounchecked builds).

Declaration

func +(lhs: Self, rhs: Self) -> Self
func /(_:rhs:) Required

Divide lhs and rhs, returning a result and trapping in case of arithmetic overflow (except in -Ounchecked builds).

Declaration

func /(lhs: Self, rhs: Self) -> Self
func <(_:rhs:) Required

A strict total order over instances of Self

Declaration

func <(lhs: Self, rhs: Self) -> Bool

Declared In

_Comparable
func <=(_:rhs:)

Declaration

func <=(lhs: Self, rhs: Self) -> Bool

Declared In

Comparable
func ==(_:rhs:) Required

Return true if lhs is equal to rhs.

Equality implies substitutability. When x == y, x and y are interchangeable in any code that only depends on their values.

Class instance identity as distinguished by triple-equals === is notably not part of an instance's value. Exposing other non-value aspects of Equatable types is discouraged, and any that are exposed should be explicitly pointed out in documentation.

Equality is an equivalence relation

  • x == x is true
  • x == y implies y == x
  • x == y and y == z implies x == z

Inequality is the inverse of equality, i.e. !(x == y) iff x != y

Declaration

func ==(lhs: Self, rhs: Self) -> Bool

Declared In

Equatable
func >(_:rhs:)

Declaration

func >(lhs: Self, rhs: Self) -> Bool

Declared In

Comparable
func >=(_:rhs:)

Declaration

func >=(lhs: Self, rhs: Self) -> Bool

Declared In

Comparable
func -(_:rhs:) Required

Subtract lhs and rhs, returning a result and trapping in case of arithmetic overflow (except in -Ounchecked builds).

Declaration

func -(lhs: Self, rhs: Self) -> Self
func toIntMax() Required

Explicitly convert to IntMax, trapping on overflow (except in -Ounchecked builds).

Declaration

func toIntMax() -> IntMax