Operator 演算子

&+(_:_:)

Returns the sum of the two given values, wrapping the result in case of any overflow. 2つの与えられた値の合計を返します、何らかのオーバーフローの場合には結果をラップします。

Declaration 宣言

static func &+ (lhs: UInt8, rhs: UInt8) -> UInt8

Parameters パラメータ

lhs

The first value to add. 加算する第1の値。

rhs

The second value to add. 加算する第2の値。

Discussion 解説

The overflow addition operator (&+) discards any bits that overflow the fixed width of the integer type. In the following example, the sum of 100 and 121 is greater than the maximum representable Int8 value, so the result is the partial value after discarding the overflowing bits. オーバーフロー加算演算子(&+)は、固定幅の整数型からオーバーフローするあらゆるビットを廃棄します。以下の例において、100121の合計は、最大限表現可能なInt8値より大きいです、それで結果はオーバーフローするビットを廃棄後の部分的な値です。


let x: Int8 = 10 &+ 21
// x == 31
let y: Int8 = 100 &+ 121
// y == -35 (after overflow)

For more about arithmetic with overflow operators, see Overflow Operators in The Swift Programming Language. オーバーフロー演算子を使う算術についてさらには、オーバーフロー演算子Swiftプログラミング言語で見てください。