Int16

struct Int16

A 16-bit signed integer value type.

Inheritance BidirectionalIndexType, BitwiseOperationsType, CVarArgType, Comparable, Equatable, ForwardIndexType, Hashable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, Printable, RandomAccessIndexType, Reflectable, SignedIntegerType, SignedNumberType, Strideable, _BidirectionalIndexType, _Comparable, _ForwardIndexType, _Incrementable, _IntegerArithmeticType, _IntegerType, _RandomAccessIndexType, _SignedIntegerType, _SignedNumberType, _Strideable 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)

Create an instance initialized to value.

Declaration

init(_ value: Int16)
init(_: Int32)

Declaration

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

Declaration

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

Declaration

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

Declaration

init(_ v: 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(bigEndian:)

Creates an integer from its big-endian representation, changing the byte order if necessary.

Declaration

init(bigEndian value: Int16)
init(bitPattern:)

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

Declaration

init(bitPattern: UInt16)
init(integerLiteral:)

Create an instance initialized to value.

Declaration

init(integerLiteral value: Int16)
init(littleEndian:)

Creates an integer from its little-endian representation, changing the byte order if necessary.

Declaration

init(littleEndian value: Int16)
init(truncatingBitPattern: Int)

Construct a Int16 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: Int32)

Construct a Int16 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 Int16 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 Int16 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: UInt32)

Construct a Int16 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 Int16 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)

Static Variables

static var allZeros: Int16

The empty bitset of type Int16.

Declaration

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

Declaration

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

Declaration

static var min: Int16 { get }

Instance Variables

var bigEndian: Int16

Returns the big-endian representation of the integer, changing the byte order if necessary.

Declaration

var bigEndian: Int16 { get }
var byteSwapped: Int16

Returns the current integer with the byte order swapped.

Declaration

var byteSwapped: Int16 { get }
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 }
var littleEndian: Int16

Returns the little-endian representation of the integer, changing the byte order if necessary.

Declaration

var littleEndian: Int16 { get }
var value: Builtin.Int16

Declaration

var value: Builtin.Int16 { get set }

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

Instance Methods

func advancedBy(_:)

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)

Declaration

func advancedBy(amount: Distance) -> Int16
func distanceTo(_:)

Return the minimum number of applications of successor or predecessor required to reach other from self.

Complexity: O(1).

Declaration

func distanceTo(other: Int16) -> Distance
func encode()

Transform self into a series of machine words that can be appropriately interpreted by C varargs

Declaration

func encode() -> [Word]
func getMirror()

Returns a mirror that reflects self.

Declaration

func getMirror() -> MirrorType
func predecessor()

Returns the previous consecutive value before self.

Requires: the previous value is representable.

Declaration

func predecessor() -> Int16
func successor()

Returns the next consecutive value after self.

Requires: the next value is representable.

Declaration

func successor() -> Int16
func toIntMax()

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

Declaration

func toIntMax() -> IntMax