struct Int16
Inheritance |
BidirectionalIndexType, BitwiseOperationsType, CVarArgType, Comparable, CustomStringConvertible, Equatable, ForwardIndexType, Hashable, IntegerArithmeticType, IntegerLiteralConvertible, IntegerType, RandomAccessIndexType, SignedIntegerType, SignedNumberType, Strideable, _Incrementable, _IntegerArithmeticType, _IntegerType, _RandomAccessAmbiguity, _Reflectable, _SignedIntegerType
View Protocol Hierarchy →
|
---|---|
Associated Types | |
Import | import Swift |
Initializers
Creates an integer from its big-endian representation, changing the byte order if necessary.
Declaration
init(bigEndian value: Int16)
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)
Create an instance initialized to value
.
Declaration
init(integerLiteral value: Int16)
Creates an integer from its little-endian representation, changing the byte order if necessary.
Declaration
init(littleEndian value: Int16)
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)
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)
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)
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)
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)
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)
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
The empty bitset of type Int16.
Declaration
static var allZeros: Int16 { get }
Instance Variables
Returns the big-endian representation of the integer, changing the byte order if necessary.
Declaration
var bigEndian: Int16 { get }
Returns the current integer with the byte order swapped.
Declaration
var byteSwapped: Int16 { get }
A textual representation of self
.
Declaration
var description: String { get }
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 }
Returns the little-endian representation of the integer, changing the byte order if necessary.
Declaration
var littleEndian: Int16 { get }
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: Int16, _ rhs: Int16) -> (Int16, overflow: Bool)
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)
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)
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)
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
Declaration
func advancedBy(n: Distance) -> Int16
Declared In
Int16
, BidirectionalIndexType
, _RandomAccessAmbiguity
, ForwardIndexType
Declaration
func advancedBy(n: Int16.Distance, limit: Int16) -> Int16
Declared In
RandomAccessIndexType
, BidirectionalIndexType
, ForwardIndexType
Declaration
func distanceTo(other: Int16) -> Distance
Declared In
Int16
, BidirectionalIndexType
, ForwardIndexType
Returns the previous consecutive value before self
.
Requires: The previous value is representable.
Declaration
func predecessor() -> Int16
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: Int16, by stride: Int16.Stride) -> StrideThrough<Int16>
Declared In
Strideable
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: Int16, by stride: Int16.Stride) -> StrideTo<Int16>
Declared In
Strideable
Returns the next consecutive value after self
.
Requires: The next value is representable.
Declaration
func successor() -> Int16
Represent this number using Swift's widest native signed integer type.
Declaration
func toIntMax() -> IntMax
A 16-bit signed integer value type.