Operator 演算子

&*=(_:_:)

Multiplies two values and stores the result in the left-hand-side variable, wrapping any overflow. 2つの値を乗算して結果を左手側の変数に格納します、あらゆるオーバーフローをラップします。

Declaration 宣言

static func &*= (lhs: inout UInt8, rhs: UInt8)

Parameters パラメータ

lhs

The first value to multiply. 掛け合わされる第1の値。

rhs

The second value to multiply. 掛け合わされる第2の値。

Discussion 解説

The masking multiplication assignment operator (&*=) silently wraps any overflow that occurs during the operation. In the following example, the product of 10 and 50 is greater than the maximum representable Int8 value, so the result is the partial value after discarding the overflowing bits. マスク乗算代入演算子(&*=)は、演算の間に起こるあらゆるオーバーフローを黙ってラップします。以下の例において、1050の積は、最大限表現可能なInt8値より大きいです、それで結果はオーバーフローするビットを廃棄後の部分的な値です。


var x: Int8 = 10
x &*= 5
// x == 50
var y: Int8 = 10
y &*= 50
// y == -12 (after overflow)

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