UInt8

struct UInt8

An 8-bit unsigned integer value type.

Inheritance BidirectionalIndexType, BitwiseOperationsType, CVarArgType, Comparable, CustomStringConvertible, Equatable, ForwardIndexType, Hashable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, RandomAccessIndexType, Strideable, UnsignedIntegerType, _DisallowMixedSignArithmetic, _Incrementable, _IntegerArithmeticType, _IntegerType, _RandomAccessAmbiguity, _Reflectable View Protocol Hierarchy →
Associated Types
Distance = Int

A type that can represent the number of steps between pairs of values.

Import import Swift

Initializers

init()

Create an instance initialized to zero.

Declaration

init()
init(_: Double)

Construct an instance that approximates other.

Declaration

init(_ other: Double)
init(_: Float)

Construct an instance that approximates other.

Declaration

init(_ other: Float)
init(_: Float80)

Construct an instance that approximates other.

Declaration

init(_ other: Float80)
init(_: Int)

Declaration

init(_ v: Int)
init(_: Int8)

Declaration

init(_ v: Int8)
init(_: Int16)

Declaration

init(_ v: Int16)
init(_: Int32)

Declaration

init(_ v: Int32)
init(_: Int64)

Declaration

init(_ v: Int64)
init(_: UInt)

Declaration

init(_ v: UInt)
init(_: UInt8)

Create an instance initialized to value.

Declaration

init(_ value: UInt8)
init(_: UInt16)

Declaration

init(_ v: UInt16)
init(_: UInt32)

Declaration

init(_ v: UInt32)
init(_: UInt64)

Declaration

init(_ v: UInt64)
init(_builtinIntegerLiteral:)

Declaration

init(_builtinIntegerLiteral value: Builtin.Int2048)
init(ascii:)

Construct with value v.value.

Requires: v.value can be represented as ASCII (0..<128).

Declaration

init(ascii v: UnicodeScalar)
init(bitPattern:)

Construct a UInt8 having the same memory representation as the Int8 bitPattern. No range or overflow checking occurs, and the resulting UInt8 may not have the same numeric value as bitPattern--it is only guaranteed to use the same pattern of bits.

Declaration

init(bitPattern: Int8)
init(integerLiteral:)

Create an instance initialized to value.

Declaration

init(integerLiteral value: UInt8)
init(truncatingBitPattern: Int)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: Int)
init(truncatingBitPattern: Int16)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: Int16)
init(truncatingBitPattern: Int32)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: Int32)
init(truncatingBitPattern: Int64)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: Int64)
init(truncatingBitPattern: UInt)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: UInt)
init(truncatingBitPattern: UInt16)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: UInt16)
init(truncatingBitPattern: UInt32)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: UInt32)
init(truncatingBitPattern: UInt64)

Construct a UInt8 having the same bitwise representation as the least significant bits of the provided bit pattern.

No range or overflow checking occurs.

Declaration

init(truncatingBitPattern: UInt64)
init?(_:radix:)

Construct from an ASCII representation in the given radix.

If text does not match the regular expression "[+-]?[0-9a-zA-Z]+", or the value it denotes in the given radix is not representable, the result is nil.

Declaration

init?(_ text: String, radix: Int = default)

Static Variables

static var allZeros: UInt8

The empty bitset of type UInt8.

Declaration

static var allZeros: UInt8 { get }
static var max: UInt8

Declaration

static var max: UInt8 { get }
static var min: UInt8

Declaration

static var min: UInt8 { get }

Instance Variables

var description: String

A textual representation of self.

Declaration

var description: String { get }
var hashValue: Int

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 }

Static Methods

static func addWithOverflow(_:_:)

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: UInt8, _ rhs: UInt8) -> (UInt8, overflow: Bool)
static func divideWithOverflow(_:_:)

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: UInt8, _ rhs: UInt8) -> (UInt8, overflow: Bool)
static func multiplyWithOverflow(_:_:)

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: UInt8, _ rhs: UInt8) -> (UInt8, overflow: Bool)
static func remainderWithOverflow(_:_:)

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: UInt8, _ rhs: UInt8) -> (UInt8, overflow: Bool)
static func subtractWithOverflow(_:_:)

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: UInt8, _ rhs: UInt8) -> (UInt8, overflow: Bool)

Instance Methods

func advancedBy(_:limit:)

Returns the result of advancing self by n positions, or until it equals limit.

Returns: - If n > 0, the result of applying successor to self n times but not past limit. - If n < 0, the result of applying predecessor to self -n times but not past limit. - Otherwise, self.

Requires: n >= 0 if only conforming to ForwardIndexType.

Complexity: - O(1) if conforming to RandomAccessIndexType - O(abs(n)) otherwise

Declaration

func advancedBy(n: UInt8.Distance, limit: UInt8) -> UInt8

Declared In

IntegerType, RandomAccessIndexType, BidirectionalIndexType, ForwardIndexType
func distanceTo(_:)

Declaration

func distanceTo(other: UInt8) -> Distance

Declared In

UInt8, IntegerType, RandomAccessIndexType, BidirectionalIndexType, ForwardIndexType
func predecessor()

Returns the previous consecutive value before self.

Requires: The previous value is representable.

Declaration

func predecessor() -> UInt8
func stride(through:by:)

Returns the sequence of values (self, self + stride, self + stride + stride, ... last) where last is the last value in the progression less than or equal to end.

Note: There is no guarantee that end is an element of the sequence.

Declaration

func stride(through end: UInt8, by stride: UInt8.Stride) -> StrideThrough<UInt8>

Declared In

IntegerType, RandomAccessIndexType, Strideable
func stride(to:by:)

Returns the sequence of values (self, self + stride, self + stride + stride, ... last) where last is the last value in the progression that is less than end.

Declaration

func stride(to end: UInt8, by stride: UInt8.Stride) -> StrideTo<UInt8>

Declared In

IntegerType, RandomAccessIndexType, Strideable
func successor()

Returns the next consecutive value after self.

Requires: The next value is representable.

Declaration

func successor() -> UInt8
func toIntMax()

Explicitly convert to IntMax.

Declaration

func toIntMax() -> IntMax
func toUIntMax()

Represent this number using Swift's widest native unsigned integer type.

Declaration

func toUIntMax() -> UIntMax