protocol UnsignedIntegerType
Inheritance 
BidirectionalIndexType, BitwiseOperationsType, Comparable, Equatable, ForwardIndexType, Hashable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, Printable, RandomAccessIndexType, Strideable, _BidirectionalIndexType, _Comparable, _ForwardIndexType, _Incrementable, _IntegerArithmeticType, _IntegerType, _RandomAccessIndexType, _Strideable, _UnsignedIntegerType
View Protocol Hierarchy →


Associated Types 
IntegerLiteralType
Distance : _SignedIntegerType = Int
A type that can represent the number of steps between pairs of
Reachability is defined by the ability to produce one value from
the other via zero or more applications of _DisabledRangeIndex = _DisabledRangeIndex_
A type that can represent the number of steps between pairs of
Reachability is defined by the ability to produce one value from
the other via zero or more applications of Stride : SignedNumberType
A type that can represent the distance between two values of _DisallowMixedSignArithmetic : SignedIntegerType = Int

Import  import Swift 
Initializers
Create an instance initialized to value
.
Declaration
init(integerLiteral value: IntegerLiteralType)
Declared In
IntegerLiteralConvertible
Convert from Swift's widest unsigned integer type, trapping on overflow.
Declaration
init(_: UIntMax)
Declared In
_UnsignedIntegerType
Static Variables
The empty bitset.
Also the identity element for 
and
^
, and the fixed point for
&
.
Declaration
static var allZeros: Self { get }
Declared In
BitwiseOperationsType
Instance Variables
The hash value.
Axiom: x == y
implies x.hashValue == y.hashValue
Note: the hash value is not guaranteed to be stable across different invocations of the same program. Do not persist the hash value across program runs.
Declaration
var hashValue: Int { get }
Declared In
Hashable
Static Methods
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
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
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
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
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
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
Declared In
IntegerArithmeticType
Returns the intersection of bits set in lhs
and rhs
.
Complexity: O(1)
Declaration
func &(lhs: Self, rhs: Self) > Self
Declared In
BitwiseOperationsType
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
Declared In
IntegerArithmeticType
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
Declared In
IntegerArithmeticType
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
Declared In
IntegerArithmeticType
A strict total order
over instances of Self
Declaration
func <(lhs: Self, rhs: Self) > Bool
Declared In
_Comparable
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 tripleequals ===
is notably not part of an instance's value. Exposing other
nonvalue 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
istrue
x == y
impliesy == x
x == y
andy == z
impliesx == z
Inequality is the inverse of equality, i.e. !(x == y)
iff
x != y
Declaration
func ==(lhs: Self, rhs: Self) > Bool
Declared In
Equatable
Returns the bits that are set in exactly one of lhs
and rhs
Complexity: O(1)
Declaration
func ^(lhs: Self, rhs: Self) > Self
Declared In
BitwiseOperationsType
Returns the union of bits set in lhs
and rhs
Complexity: O(1)
Declaration
func (lhs: Self, rhs: Self) > Self
Declared In
BitwiseOperationsType
Returns x ^ ~Self.allZeros
Complexity: O(1)
Declaration
prefix func ~(x: Self) > Self
Declared In
BitwiseOperationsType
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
Declared In
IntegerArithmeticType
Return self
offset by n
steps.
Returns: If n > 0
, the result of applying successor
to
self
n
times. If n < 0
, the result of applying
predecessor
to self
n
times. Otherwise, self
.
Complexity: O(1)
Axioms:
x.advancedBy(0) == x
x.advancedBy(1) == x.successor()
x.advancedBy(1) == x.predecessor()
x.distanceTo(x.advancedBy(m)) == m
Declaration
func advancedBy(n: Self.Distance) > Self
Declared In
_RandomAccessIndexType
, _Strideable
Return the minimum number of applications of successor
or
predecessor
required to reach other
from self
.
Complexity: O(1).
Axioms:
x.distanceTo(x.successor())) == 1
x.distanceTo(x.predecessor())) == 1
x.advancedBy(x.distanceTo(y)) == y
Declaration
func distanceTo(other: Self) > Self.Distance
Declared In
_RandomAccessIndexType
, _Strideable
Return the previous consecutive value in a discrete sequence.
If self
has a welldefined successor,
self.successor().predecessor() == self
. If self
has a
welldefined predecessor, self.predecessor().successor() ==
self
.
Requires: self
has a welldefined predecessor.
Declaration
func predecessor() > Self
Declared In
_BidirectionalIndexType
Return the next consecutive value in a discrete sequence of
Self
values
Requires: self
has a welldefined successor.
Declaration
func successor() > Self
Declared In
_Incrementable
Explicitly convert to IntMax
, trapping on overflow (except in
Ounchecked builds).
Declaration
func toIntMax() > IntMax
Declared In
IntegerArithmeticType
Represent this number using Swift's widest native unsigned integer type.
Declaration
func toUIntMax() > UIntMax
Declared In
_UnsignedIntegerType
A set of common requirements for Swift's unsigned integer types.