UInt8

An 8-bit unsigned integer value type.

Inheritance BitwiseOperations, CVarArg, Comparable, CustomPlaygroundQuickLookable, CustomReflectable, CustomStringConvertible, Equatable, ExpressibleByIntegerLiteral, Hashable, Integer, IntegerArithmetic, Strideable, UnsignedInteger, _DisallowMixedSignArithmetic, _Incrementable, _Integer, _IntegerArithmetic View Protocol Hierarchy →
Import
  • import Swift

Initializers

init()

Create an instance initialized to zero.

Declaration

  • init()
init(_: Double)

Creates a new instance by rounding the given floating-point value toward zero.

other: A floating-point value. When other is rounded toward zero, the result must be within the range UInt8.min...UInt8.max.

Declaration

init(_: Float)

Creates a new instance by rounding the given floating-point value toward zero.

other: A floating-point value. When other is rounded toward zero, the result must be within the range UInt8.min...UInt8.max.

Declaration

init(_: Float80)

Creates a new instance by rounding the given floating-point value toward zero.

other: A floating-point value. When other is rounded toward zero, the result must be within the range UInt8.min...UInt8.max.

Declaration

init(_: Int)

Declaration

  • init(_ value: Int)
init(_: Int8)

Declaration

init(_: Int16)

Declaration

init(_: Int32)

Declaration

init(_: Int64)

Declaration

init(_: UInt)

Declaration

init(_: UInt8)

Declaration

init(_: UInt16)

Declaration

init(_: UInt32)

Declaration

init(_: UInt64)

Convert from Swift's widest unsigned integer type, trapping on overflow.

Declaration

init(ascii:)

Construct with value v.value.

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

Declaration

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?(exactly: Int)

Declaration

  • init?(exactly value: Int)
init?(exactly: Int8)

Declaration

  • init?(exactly value: Int8)
init?(exactly: Int16)

Declaration

  • init?(exactly value: Int16)
init?(exactly: Int32)

Declaration

  • init?(exactly value: Int32)
init?(exactly: Int64)

Declaration

  • init?(exactly value: Int64)
init?(exactly: UInt)

Declaration

  • init?(exactly value: UInt)
init?(exactly: UInt8)

Declaration

  • init?(exactly value: UInt8)
init?(exactly: UInt16)

Declaration

init?(exactly: UInt32)

Declaration

init?(exactly: UInt64)

Declaration

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 customMirror: Mirror

A mirror that reflects the UInt8 instance.

Declaration

  • var customMirror: Mirror { get }
var customPlaygroundQuickLook: PlaygroundQuickLook

A custom playground Quick Look for this instance.

If this type has value semantics, the PlaygroundQuickLook instance should be unaffected by subsequent mutations.

Declaration

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 divideWithOverflow(_:_:)

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

Declaration

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 remainderWithOverflow(_:_:)

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

Declaration

static func subtractWithOverflow(_:_:)

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

Declaration

Instance Methods

func advanced(by:)

Returns a Self x such that self.distance(to: x) approximates n.

If Stride conforms to Integer, then self.distance(to: x) == n.

Complexity: O(1).

Declaration

Declared In

UnsignedInteger
func distance(to:)

Returns a stride x such that self.advanced(by: x) approximates other.

If Stride conforms to Integer, then self.advanced(by: x) == other.

Complexity: O(1).

Declaration

Declared In

UnsignedInteger
func toIntMax()

Explicitly convert to IntMax.

Declaration

func toUIntMax()

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

Declaration

2 inherited items hidden. (Show all)