enum FloatingPointSign
The sign of a floatingpoint value.
Inheritance  Int, Codable, CustomReflectable, Hashable, SIMDScalar 

Associated Types 
public typealias SIMDMaskScalar = Int

Nested Types  Int.SIMD2Storage, Int.SIMD4Storage, Int.SIMD8Storage, Int.SIMD16Storage, Int.SIMD32Storage, Int.SIMD64Storage 
Cases
Initializers
Creates a new value with the bit pattern of the given pointer.
The new value represents the address of the pointer passed as pointer
.
If pointer
is nil
, the result is 0
.
 Parameter pointer: The pointer to use as the source for the new integer.
Declaration
@inlinable public init(bitPattern pointer: OpaquePointer?)
Creates an integer that captures the full value of the given object identifier.
Declaration
@inlinable public init(bitPattern objectID: ObjectIdentifier)
Creates a new value with the bit pattern of the given pointer.
The new value represents the address of the pointer passed as pointer
.
If pointer
is nil
, the result is 0
.
 Parameter pointer: The pointer to use as the source for the new integer.
Declaration
public init<P>(bitPattern pointer: P?) where P: _Pointer
Creates a new instance by decoding from the given decoder.
This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.
 Parameter decoder: The decoder to read data from.
Declaration
public init(from decoder: Decoder) throws
Creates a new instance with the specified raw value.
If there is no value of the type that corresponds with the specified raw
value, this initializer returns nil
. For example:
enum PaperSize: String {
case A4, A5, Letter, Legal
}
print(PaperSize(rawValue: "Legal"))
// Prints "Optional("PaperSize.Legal")"
print(PaperSize(rawValue: "Tabloid"))
// Prints "nil"
 Parameter rawValue: The raw value to use for the new instance.
Declaration
@inlinable public init?(rawValue: Int)
Instance Variables
A mirror that reflects the Int
instance.
Declaration
var customMirror: Mirror
A custom playground Quick Look for the Int
instance.
Declaration
var customPlaygroundQuickLook: _PlaygroundQuickLook
The hash value.
Hash values are not guaranteed to be equal across different executions of your program. Do not save hash values to use during a future execution.
Important:
hashValue
is deprecated as aHashable
requirement. To conform toHashable
, implement thehash(into:)
requirement instead.
Declaration
var hashValue: Int
The corresponding value of the raw type.
A new instance initialized with rawValue
will be equivalent to this
instance. For example:
enum PaperSize: String {
case A4, A5, Letter, Legal
}
let selectedSize = PaperSize.Letter
print(selectedSize.rawValue)
// Prints "Letter"
print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
// Prints "true"
Declaration
var rawValue: Int
The number of scalars, or elements, in the vector.
Declaration
var scalarCount: Int
The number of scalars, or elements, in the vector.
Declaration
var scalarCount: Int
The number of scalars, or elements, in the vector.
Declaration
var scalarCount: Int
The number of scalars, or elements, in the vector.
Declaration
var scalarCount: Int
The number of scalars, or elements, in the vector.
Declaration
var scalarCount: Int
The number of scalars, or elements, in the vector.
Declaration
var scalarCount: Int
Subscripts
Accesses the element at the specified index.
 Parameter index: The index of the element to access.
index
must be in the range0..<scalarCount
.
Declaration
public subscript(index: Int) > Int
Accesses the element at the specified index.
 Parameter index: The index of the element to access.
index
must be in the range0..<scalarCount
.
Declaration
public subscript(index: Int) > Int
Accesses the element at the specified index.
 Parameter index: The index of the element to access.
index
must be in the range0..<scalarCount
.
Declaration
public subscript(index: Int) > Int
Accesses the element at the specified index.
 Parameter index: The index of the element to access.
index
must be in the range0..<scalarCount
.
Declaration
public subscript(index: Int) > Int
Accesses the element at the specified index.
 Parameter index: The index of the element to access.
index
must be in the range0..<scalarCount
.
Declaration
public subscript(index: Int) > Int
Accesses the element at the specified index.
 Parameter index: The index of the element to access.
index
must be in the range0..<scalarCount
.
Declaration
public subscript(index: Int) > Int
Instance Methods
Returns a value that is offset the specified distance from this value.
Use the advanced(by:)
method in generic code to offset a value by a
specified distance. If you're working directly with numeric values, use
the addition operator (+
) instead of this method.
For a value x
, a distance n
, and a value y = x.advanced(by: n)
,
x.distance(to: y) == n
.
 Parameter n: The distance to advance this value.
Declaration
public func advanced(by n: Int) > Int
Returns the distance from this value to the given value, expressed as a stride.
For two values x
and y
, and a distance n = x.distance(to: y)
,
x.advanced(by: n) == y
.
 Parameter other: The value to calculate the distance to.
Declaration
public func distance(to other: Int) > Int
Encodes this value into the given encoder.
This function throws an error if any values are invalid for the given encoder's format.
 Parameter encoder: The encoder to write data to.
Declaration
public func encode(to encoder: Encoder) throws
Hashes the essential components of this value by feeding them into the given hasher.
Implement this method to conform to the Hashable
protocol. The
components used for hashing must be the same as the components compared
in your type's ==
operator implementation. Call hasher.combine(_:)
with each of these components.
Important: Never call
finalize()
onhasher
. Doing so may become a compiletime error in the future.
 Parameter hasher: The hasher to use when combining the components of this instance.
Declaration
@inlinable public func hash(into hasher: inout Hasher)
Hashes the essential components of this value by feeding them into the given hasher.
 Parameter hasher: The hasher to use when combining the components of this instance.
Declaration
@inlinable public func hash(into hasher: inout Hasher)
Type Methods
Returns the remainder of dividing the first value by the second.
The result of the remainder operator (%
) has the same sign as lhs
and
has a magnitude less than rhs.magnitude
.
let x = 22 % 5
// x == 2
let y = 22 % 5
// y == 2
let z = 22 % 5
// z == 2
For any two integers a
and b
, their quotient q
, and their remainder
r
, a == b * q + r
.
Declaration
public static func %(lhs: Int, rhs: Int) > Int
Returns the result of performing a bitwise AND operation on the two given values.
A bitwise AND operation results in a value that has each bit set to 1
where both of its arguments have that bit set to 1
. For example:
let x: UInt8 = 5 // 0b00000101
let y: UInt8 = 14 // 0b00001110
let z = x & y // 0b00000100
// z == 4
Declaration
public static func &(lhs: Int, rhs: 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.
Use the masking left shift operator (&<<
) when you need to perform a
shift and are sure that the shift amount is in the range
0..<lhs.bitWidth
. Before shifting, the masking left shift operator
masks the shift to this range. The shift is performed using this masked
value.
The following example defines x
as an instance of UInt8
, an 8bit,
unsigned integer type. If you use 2
as the righthandside value in an
operation on x
, the shift amount requires no masking.
let x: UInt8 = 30 // 0b00011110
let y = x &<< 2
// y == 120 // 0b01111000
However, if you use 8
as the shift amount, the method first masks the
shift amount to zero, and then performs the shift, resulting in no change
to the original value.
let z = x &<< 8
// z == 30 // 0b00011110
If the bit width of the shifted integer type is a power of two, masking is performed using a bitmask; otherwise, masking is performed using a modulo operation.
Declaration
public static func &<<(lhs: Int, rhs: 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.
Use the masking right shift operator (&>>
) when you need to perform a
shift and are sure that the shift amount is in the range
0..<lhs.bitWidth
. Before shifting, the masking right shift operator
masks the shift to this range. The shift is performed using this masked
value.
The following example defines x
as an instance of UInt8
, an 8bit,
unsigned integer type. If you use 2
as the righthandside value in an
operation on x
, the shift amount requires no masking.
let x: UInt8 = 30 // 0b00011110
let y = x &>> 2
// y == 7 // 0b00000111
However, if you use 8
as the shift amount, the method first masks the
shift amount to zero, and then performs the shift, resulting in no change
to the original value.
let z = x &>> 8
// z == 30 // 0b00011110
If the bit width of the shifted integer type is a power of two, masking is performed using a bitmask; otherwise, masking is performed using a modulo operation.
Declaration
public static func &>>(lhs: Int, rhs: Int) > Int
Multiplies two values and produces their product.
The multiplication operator (*
) calculates the product of its two
arguments. For example:
2 * 3 // 6
100 * 21 // 2100
10 * 15 // 150
3.5 * 2.25 // 7.875
You cannot use *
with arguments of different types. To multiply values
of different types, convert one of the values to the other value's type.
let x: Int8 = 21
let y: Int = 1000000
Int(x) * y // 21000000
The product of the two arguments must be representable in the arguments'
type. In the following example, the result of 21 * 21
is greater than
the maximum representable Int8
value:
x * 21 // Overflow error
Note: Overflow checking is not performed in
Ounchecked
builds.
If you want to opt out of overflow checking and wrap the result in case
of any overflow, use the overflow multiplication operator (&*
).
x &* 21 // 115
Declaration
public static func *(lhs: Int, rhs: Int) > Int
Adds two values and produces their sum.
The addition operator (+
) calculates the sum of its two arguments. For
example:
1 + 2 // 3
10 + 15 // 5
15 + 5 // 20
21.5 + 3.25 // 24.75
You cannot use +
with arguments of different types. To add values of
different types, convert one of the values to the other value's type.
let x: Int8 = 21
let y: Int = 1000000
Int(x) + y // 1000021
The sum of the two arguments must be representable in the arguments'
type. In the following example, the result of 21 + 120
is greater than
the maximum representable Int8
value:
x + 120 // Overflow error
Note: Overflow checking is not performed in
Ounchecked
builds.
If you want to opt out of overflow checking and wrap the result in case
of any overflow, use the overflow addition operator (&+
).
x &+ 120 // 115
Declaration
public static func +(lhs: Int, rhs: Int) > Int
Subtracts one value from another and produces their difference.
The subtraction operator (
) calculates the difference of its two
arguments. For example:
8  3 // 5
10  5 // 15
100  5 // 105
10.5  100.0 // 89.5
You cannot use 
with arguments of different types. To subtract values
of different types, convert one of the values to the other value's type.
let x: UInt8 = 21
let y: UInt = 1000000
y  UInt(x) // 999979
The difference of the two arguments must be representable in the
arguments' type. In the following example, the result of 21  50
is
less than zero, the minimum representable UInt8
value:
x  50 // Overflow error
Note: Overflow checking is not performed in
Ounchecked
builds.
If you want to opt out of overflow checking and wrap the result in case
of any overflow, use the overflow subtraction operator (&
).
x & 50 // 227
Declaration
public static func (lhs: Int, rhs: Int) > Int
Returns the quotient of dividing the first value by the second.
For integer types, any remainder of the division is discarded.
let x = 21 / 5
// x == 4
Declaration
public static func /(lhs: Int, rhs: Int) > Int
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
Declaration
public static func <=(lhs: Int, rhs: Int) > Bool
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values a
and b
,
a == b
implies that a != b
is false
.
Declaration
@inlinable public static func ==(a: FloatingPointSign, b: FloatingPointSign) > Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
Declaration
public static func >(lhs: Int, rhs: 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.
Declaration
public static func >=(lhs: Int, rhs: Int) > Bool
Returns the result of performing a bitwise XOR operation on the two given values.
A bitwise XOR operation, also known as an exclusive OR operation, results
in a value that has each bit set to 1
where one or the other but not
both of its arguments had that bit set to 1
. For example:
let x: UInt8 = 5 // 0b00000101
let y: UInt8 = 14 // 0b00001110
let z = x ^ y // 0b00001011
// z == 11
Declaration
public static func ^(lhs: Int, rhs: Int) > Int
Returns the result of performing a bitwise OR operation on the two given values.
A bitwise OR operation results in a value that has each bit set to 1
where one or both of its arguments have that bit set to 1
. For
example:
let x: UInt8 = 5 // 0b00000101
let y: UInt8 = 14 // 0b00001110
let z = x  y // 0b00001111
// z == 15
Declaration
public static func (lhs: Int, rhs: Int) > Int
The sign for a negative value.
Declaration
case minus