IntegerArithmetic

protocol IntegerArithmetic

The common requirements for types that support integer arithmetic.

Inheritance Comparable, Equatable, _IntegerArithmetic View Protocol Hierarchy →
Import import Swift

Static Methods

static func addWithOverflow(_:_:) Required

Adds lhs and rhs, returning the 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

_IntegerArithmetic
static func divideWithOverflow(_:_:) Required

Divides lhs and rhs, returning the 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

_IntegerArithmetic
static func multiplyWithOverflow(_:_:) Required

Multiplies lhs and rhs, returning the 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

_IntegerArithmetic
static func remainderWithOverflow(_:_:) Required

Divides 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

_IntegerArithmetic
static func subtractWithOverflow(_:_:) Required

Subtracts lhs and rhs, returning the 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

_IntegerArithmetic

Instance Methods

func %(_:rhs:) Required

Divides 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

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

Declaration

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

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

Declaration

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

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

Declaration

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

Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.

This function is the only requirement of the Comparable protocol. The remainder of the relational operator functions are implemented by the standard library for any type that conforms to Comparable.

Parameters: lhs: A value to compare. rhs: Another value to compare.

Declaration

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

Declared In

Comparable
func <=(_:rhs:)

Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.

Parameters: lhs: A value to compare. rhs: Another value to compare.

Declaration

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

Declared In

Comparable
func ==(_:rhs:) Required

Returns a Boolean value indicating whether two values are equal.

Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

Parameters: lhs: A value to compare. rhs: Another value to compare.

Declaration

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

Declared In

Equatable
func >(_:rhs:)

Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.

Parameters: lhs: A value to compare. rhs: Another value to compare.

Declaration

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

Declared In

Comparable
func >=(_:rhs:)

Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.

Parameters: lhs: A value to compare. rhs: Another value to compare.

Declaration

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

Declared In

Comparable
func -(_:rhs:) Required

Subtracts lhs and rhs, returning the 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