Int
A signed integer value type.
@frozen struct Int
Overview
On 32-bit platforms, Int
is the same size as Int32
, and on 64-bit platforms, Int
is the same size as Int64
.
A signed integer value type.
@frozen struct Int
On 32-bit platforms, Int
is the same size as Int32
, and on 64-bit platforms, Int
is the same size as Int64
.
typealias AtomicWrapper
typealias IntegerLiteralType
A type that represents an integer literal.
typealias Magnitude
A type that can represent the absolute value of any possible value of this type.
typealias SIMDMaskScalar
init()
Creates a new value equal to zero.
init(integerLiteral: Self)
Creates an instance initialized to the specified integer value.
init?(String)
Creates a new integer value from the given string.
init<T>(T)
Creates an integer from the given floating-point value, rounding toward zero. Any fractional part of the value passed as source
is removed.
init?<S>(S, radix: Int)
Creates a new integer value from the given string and radix.
init(bigEndian: Self)
Creates an integer from its big-endian representation, changing the byte order if necessary.
init<Other>(clamping: Other)
Creates a new instance with the representable value that’s closest to the given integer.
init?<T>(exactly: T)
Creates an integer from the given floating-point value, if it can be represented exactly.
init(littleEndian: Self)
Creates an integer from its little-endian representation, changing the byte order if necessary.
init<T>(truncatingIfNeeded: T)
Creates a new instance from the bit pattern of the given instance by truncating or sign-extending if needed to fit this type.
init(Double)
Creates an integer from the given floating-point value, rounding toward zero.
init(Float80)
Creates an integer from the given floating-point value, rounding toward zero.
init(Float16)
Creates an integer from the given floating-point value, rounding toward zero.
init(Float)
Creates an integer from the given floating-point value, rounding toward zero.
init<P>(bitPattern: P?)
Creates a new value with the bit pattern of the given pointer.
init(bitPattern: UInt)
Creates a new instance with the same memory representation as the given value.
init(bitPattern: ObjectIdentifier)
Creates an integer that captures the full value of the given object identifier.
init(bitPattern: OpaquePointer?)
Creates a new value with the bit pattern of the given pointer.
init?<T>(codingKey: T)
init?(exactly: Float)
Creates an integer from the given floating-point value, if it can be represented exactly.
init?(exactly: Float80)
Creates an integer from the given floating-point value, if it can be represented exactly.
init?(exactly: Float16)
Creates an integer from the given floating-point value, if it can be represented exactly.
init?(exactly: Double)
Creates an integer from the given floating-point value, if it can be represented exactly.
init(from: Decoder) throws
Creates a new instance by decoding from the given decoder.
init(webSocketOpcode: WebSocketOpcode)
Create a UInt8 corresponding to the integer value for a given WebSocketOpcode
.
init<T>(T)
Creates a new instance from the given integer.
init?<T>(exactly: T)
Creates a new instance from the given integer, if it can be represented exactly.
static var zero: Self
The zero value.
static let atomic_add: (OpaquePointer, Int) -> Int
static let atomic_compare_and_exchange: (OpaquePointer, Int, Int) -> Bool
static let atomic_create: (Int) -> OpaquePointer
static let atomic_destroy: (OpaquePointer) -> Void
static let atomic_exchange: (OpaquePointer, Int) -> Int
static let atomic_load: (OpaquePointer) -> Int
static let atomic_store: (OpaquePointer, Int) -> Void
static let atomic_sub: (OpaquePointer, Int) -> Int
static var bitWidth: Int
The number of bits used for the underlying binary representation of values of this type.
static let nio_atomic_add: (UnsafeMutablePointer<catmc_nio_atomic_long>, Int) -> Int
static let nio_atomic_compare_and_exchange: (UnsafeMutablePointer<catmc_nio_atomic_long>, Int, Int) -> Bool
static let nio_atomic_create_with_existing_storage: (UnsafeMutablePointer<catmc_nio_atomic_long>, Int) -> Void
static let nio_atomic_exchange: (UnsafeMutablePointer<catmc_nio_atomic_long>, Int) -> Int
static let nio_atomic_load: (UnsafeMutablePointer<catmc_nio_atomic_long>) -> Int
static let nio_atomic_store: (UnsafeMutablePointer<catmc_nio_atomic_long>, Int) -> Void
static let nio_atomic_sub: (UnsafeMutablePointer<catmc_nio_atomic_long>, Int) -> Int
static var isSigned: Bool
A Boolean value indicating whether this type is a signed integer type.
static var max: Self
The maximum representable integer in this type.
static var min: Self
The minimum representable integer in this type.
var description: String
A textual representation of this value.
var bigEndian: Self
The big-endian representation of this integer.
var bitWidth: Int
The number of bits in the binary representation of this value.
var littleEndian: Self
The little-endian representation of this integer.
var byteSwapped: Int
A representation of this integer with the byte order swapped.
var codingKey: CodingKey
var customMirror: Mirror
A mirror that reflects the Int
instance.
var leadingZeroBitCount: Int
The number of leading zeros in this value’s binary representation.
var magnitude: UInt
The magnitude of this value.
var nonzeroBitCount: Int
The number of bits equal to 1 in this value’s binary representation.
var trailingZeroBitCount: Int
The number of trailing zeros in this value’s binary representation.
var words: Int.Words
A collection containing the words of this value’s binary representation, in order from the least significant to most significant.
static func random(in: Range<Self>) -> Self
Returns a random value within the specified range.
static func random(in: ClosedRange<Self>) -> Self
Returns a random value within the specified range.
static func random<T>(in: Range<Self>, using: inout T) -> Self
Returns a random value within the specified range, using the given generator as a source for randomness.
static func random<T>(in: ClosedRange<Self>, using: inout T) -> Self
Returns a random value within the specified range, using the given generator as a source for randomness.
func quotientAndRemainder(dividingBy: Self) -> (quotient: Self, remainder: Self)
Returns the quotient and remainder of this value divided by the given value.
func addingReportingOverflow(Int) -> (partialValue: Int, overflow: Bool)
Returns the sum of this value and the given value, along with a Boolean value indicating whether overflow occurred in the operation.
func advanced(by: Int) -> Int
Returns a value that is offset the specified distance from this value.
func distance(to: Int) -> Int
Returns the distance from this value to the given value, expressed as a stride.
func dividedReportingOverflow(by: Int) -> (partialValue: Int, overflow: Bool)
Returns the quotient obtained by dividing this value by the given value, along with a Boolean value indicating whether overflow occurred in the operation.
func dividingFullWidth((high: Int, low: Int.Magnitude)) -> (quotient: Int, remainder: Int)
Returns a tuple containing the quotient and remainder of dividing the given value by this value.
func encode(to: Encoder) throws
Encodes this value into the given encoder.
func hash(into: inout Hasher)
Hashes the essential components of this value by feeding them into the given hasher.
func multipliedFullWidth(by: Int) -> (high: Int, low: Int.Magnitude)
Returns a tuple containing the high and low parts of the result of multiplying this value by the given value.
func multipliedReportingOverflow(by: Int) -> (partialValue: Int, overflow: Bool)
Returns the product of this value and the given value, along with a Boolean value indicating whether overflow occurred in the operation.
func remainderReportingOverflow(dividingBy: Int) -> (partialValue: Int, overflow: Bool)
Returns the remainder after dividing this value by the given value, along with a Boolean value indicating whether overflow occurred during division.
func signum() -> Int
Returns -1
if this value is negative and 1
if it’s positive; otherwise, 0
.
func subtractingReportingOverflow(Int) -> (partialValue: Int, overflow: Bool)
Returns the difference obtained by subtracting the given value from this value, along with a Boolean value indicating whether overflow occurred in the operation.
func isMultiple(of: Self) -> Bool
Returns true
if this value is a multiple of the given value, and false
otherwise.
func negate()
Replaces this value with its additive inverse.
static func + (Self) -> Self
Returns the given number unchanged.
static func += (inout Self, Self)
Adds two values and stores the result in the left-hand-side variable.
static func -= (inout Self, Self)
Subtracts the second value from the first and stores the difference in the left-hand-side variable.
static func != (Self, Self) -> Bool
static func != <Other>(Self, Other) -> Bool
Returns a Boolean value indicating whether the two given values are not equal.
static func & (Self, Self) -> Self
Returns the result of performing a bitwise AND operation on the two given values.
static func < <Other>(Self, Other) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
static func << <RHS>(Self, RHS) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the left.
static func <= (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func <= <Other>(Self, Other) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == <Other>(Self, Other) -> Bool
Returns a Boolean value indicating whether the two given values are equal.
static func > <Other>(Self, Other) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func > (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= <Other>(Self, Other) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
static func >= (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
static func >> <RHS>(Self, RHS) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the right.
static func ^ (Self, Self) -> Self
Returns the result of performing a bitwise XOR operation on the two given values.
static func | (Self, Self) -> Self
Returns the result of performing a bitwise OR operation on the two given values.
static func ... (Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (Self, Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (Self, Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func <= (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func > (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
static func != (Self, Self) -> Bool
static func &* (Self, Self) -> Self
Returns the product of the two given values, wrapping the result in case of any overflow.
static func &*= (inout Self, Self)
Multiplies two values and stores the result in the left-hand-side variable, wrapping any overflow.
static func &+ (Self, Self) -> Self
Returns the sum of the two given values, wrapping the result in case of any overflow.
static func &+= (inout Self, Self)
Adds two values and stores the result in the left-hand-side variable, wrapping any overflow.
static func &- (Self, Self) -> Self
Returns the difference of the two given values, wrapping the result in case of any overflow.
static func &-= (inout Self, Self)
Subtracts the second value from the first and stores the difference in the left-hand-side variable, wrapping any overflow.
static func &<< <Other>(Self, Other) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width.
static func &<< (Self, Self) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width.
static func &<<= <Other>(inout Self, Other)
Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
static func &>> (Self, Self) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width.
static func &>> <Other>(Self, Other) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width.
static func &>>= <Other>(inout Self, Other)
Calculates the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
static func << <Other>(Self, Other) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the left.
static func <<= <Other>(inout Self, Other)
Stores the result of shifting a value’s binary representation the specified number of digits to the left in the left-hand-side variable.
static func >> <Other>(Self, Other) -> Self
Returns the result of shifting a value’s binary representation the specified number of digits to the right.
static func >>= <Other>(inout Self, Other)
Stores the result of shifting a value’s binary representation the specified number of digits to the right in the left-hand-side variable.
static func ~ (Self) -> Self
Returns the inverse of the bits set in the argument.
static func % (Int, Int) -> Int
Returns the remainder of dividing the first value by the second.
static func %= (inout Int, Int)
Divides the first value by the second and stores the remainder in the left-hand-side variable.
static func & (Int, Int) -> Int
Returns the result of performing a bitwise AND operation on the two given values.
static func &<< (Int, Int) -> Int
Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width.
static func &<<= (inout Int, Int)
Returns the result of shifting a value’s binary representation the specified number of digits to the left, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
static func &= (inout Int, Int)
Stores the result of performing a bitwise AND operation on the two given values in the left-hand-side variable.
static func &>> (Int, Int) -> Int
Returns the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width.
static func &>>= (inout Int, Int)
Calculates the result of shifting a value’s binary representation the specified number of digits to the right, masking the shift amount to the type’s bit width, and stores the result in the left-hand-side variable.
static func * (Int, Int) -> Int
Multiplies two values and produces their product.
static func *= (inout Int, Int)
Multiplies two values and stores the result in the left-hand-side variable.
static func + (Int, Int) -> Int
Adds two values and produces their sum.
static func += (inout Int, Int)
Adds two values and stores the result in the left-hand-side variable.
static func - (Int, Int) -> Int
Subtracts one value from another and produces their difference.
static func -= (inout Int, Int)
Subtracts the second value from the first and stores the difference in the left-hand-side variable.
static func / (Int, Int) -> Int
Returns the quotient of dividing the first value by the second.
static func /= (inout Int, Int)
Divides the first value by the second and stores the quotient in the left-hand-side variable.
static func < (Int, Int) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
static func <= (Int, Int) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == (Int, Int) -> Bool
Returns a Boolean value indicating whether two values are equal.
static func > (Int, Int) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (Int, Int) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
static func ^ (Int, Int) -> Int
Returns the result of performing a bitwise XOR operation on the two given values.
static func ^= (inout Int, Int)
Stores the result of performing a bitwise XOR operation on the two given values in the left-hand-side variable.
static func | (Int, Int) -> Int
Returns the result of performing a bitwise OR operation on the two given values.
static func |= (inout Int, Int)
Stores the result of performing a bitwise OR operation on the two given values in the left-hand-side variable.
static func - (Self) -> Self
Returns the additive inverse of the specified value.
static func < (Self, Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
static func == (Self, Self) -> Bool
Returns a Boolean value indicating whether two values are equal.
struct SIMD16Storage
Storage for a vector of 16 integers.
struct SIMD2Storage
Storage for a vector of two integers.
struct SIMD32Storage
Storage for a vector of 32 integers.
struct SIMD4Storage
Storage for a vector of four integers.
struct SIMD64Storage
Storage for a vector of 64 integers.
struct SIMD8Storage
Storage for a vector of eight integers.
struct Words
A type that represents the words of this integer.
AdditiveArithmetic
AtomicPrimitive
BinaryInteger
CVarArg
CodingKeyRepresentable
Comparable
CustomReflectable
CustomStringConvertible
Decodable
Encodable
Equatable
ExpressibleByIntegerLiteral
FixedWidthInteger
Hashable
LosslessStringConvertible
MirrorPath
NIOAtomicPrimitive
Numeric
SIMDScalar
Sendable
SignedInteger
SignedNumeric
Strideable
var customPlaygroundQuickLook: _PlaygroundQuickLook
A custom playground Quick Look for the Int
instance.
Deprecated