Operatorswift 6.0.1Swift
+(_:_:)
Adds two values and produces their sum.
static func + (lhs: Int64, rhs: Int64) -> Int64
Parameters
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
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
Other members in extension
Types
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.
Typealiases
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
Type members
init(Double
) 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(Float16
) Creates an integer from the given floating-point value, rounding toward zero.
init(bitPattern: UInt64
) Creates a new instance with the same memory representation as the given value.
init?(exactly: Double
) Creates an integer from the given floating-point value, if it can be represented exactly.
init?(exactly: Float
) 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(from: any Decoder
) throws static var bitWidth: Int
The number of bits used for the underlying binary representation of values of this type.
static func != (lhs: Int64, rhs: Int64
) -> Bool static func % (lhs: Int64, rhs: Int64
) -> Int64 static func %= (lhs: inout Int64, rhs: Int64
) static func & (lhs: Int64, rhs: Int64
) -> Int64 static func &<< (lhs: Int64, rhs: Int64
) -> Int64 static func &<<= (lhs: inout Int64, rhs: Int64
) static func &= (lhs: inout Int64, rhs: Int64
) static func &>> (lhs: Int64, rhs: Int64
) -> Int64 static func &>>= (lhs: inout Int64, rhs: Int64
) static func * (lhs: Int64, rhs: Int64
) -> Int64 Multiplies two values and produces their product.
static func *= (lhs: inout Int64, rhs: Int64
) Multiplies two values and stores the result in the left-hand-side variable.
static func += (lhs: inout Int64, rhs: Int64
) Adds two values and stores the result in the left-hand-side variable.
static func - (lhs: Int64, rhs: Int64
) -> Int64 Subtracts one value from another and produces their difference.
static func -= (lhs: inout Int64, rhs: Int64
) Subtracts the second value from the first and stores the difference in the left-hand-side variable.
static func / (lhs: Int64, rhs: Int64
) -> Int64 static func /= (lhs: inout Int64, rhs: Int64
) static func < (lhs: Int64, rhs: Int64
) -> Bool static func <= (lhs: Int64, rhs: Int64
) -> Bool static func == (lhs: Int64, rhs: Int64
) -> Bool static func > (lhs: Int64, rhs: Int64
) -> Bool static func >= (lhs: Int64, rhs: Int64
) -> Bool static func ^ (lhs: Int64, rhs: Int64
) -> Int64 static func ^= (lhs: inout Int64, rhs: Int64
) static func | (lhs: Int64, rhs: Int64
) -> Int64 static func |= (lhs: inout Int64, rhs: Int64
)
Instance members
var byteSwapped: Int64
var customMirror: Mirror
A mirror that reflects the
Int64
instance.var leadingZeroBitCount: Int
The number of leading zeros in this value’s binary representation.
var magnitude: UInt64
var nonzeroBitCount: Int
var trailingZeroBitCount: Int
The number of trailing zeros in this value’s binary representation.
var words: Int64.Words
func addingReportingOverflow(Int64
) -> (partialValue: Int64, overflow: Bool) func dividedReportingOverflow(by: Int64
) -> (partialValue: Int64, overflow: Bool) func dividingFullWidth((high: Int64, low: Int64.Magnitude)
) -> (quotient: Int64, remainder: Int64) Returns a tuple containing the quotient and remainder of dividing the given value by this value.
func encode(to: any 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: Int64
) -> (high: Int64, low: Int64.Magnitude) Returns a tuple containing the high and low parts of the result of multiplying this value by the given value.
func multipliedReportingOverflow(by: Int64
) -> (partialValue: Int64, overflow: Bool) func remainderReportingOverflow(dividingBy: Int64
) -> (partialValue: Int64, overflow: Bool) func signum(
) -> Int64 func subtractingReportingOverflow(Int64
) -> (partialValue: Int64, overflow: Bool)
Show obsolete interfaces (1)
Hide obsolete interfaces
var customPlaygroundQuickLook: _PlaygroundQuickLook
A custom playground Quick Look for the
Int64
instance.