The value to divide. 除算することになる値。
Operator
演算子
%=(_:
%=(_:_:)
Divides the first value by the second and stores the remainder in the left-hand-side variable.
最初の値を2番目の値で除算して、余りを左手側の変数に格納します。
Availability
- iOS 8.0+
- iPadOS 8.0+
- macOS 10.10+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Xcode 9.0+
Technology
- Swift Standard Library Swift標準ライブラリ
Declaration 宣言
Parameters パラメータ
lhs
rhs
The value to divide
lhs
by.rhs
must not be zero. この値でlhs
を除算します。rhs
は、ゼロではなりません。
Discussion 解説
The result has the same sign as lhs
and has a magnitude less than rhs
.
結果は、lhs
と同じ符号を持ち、rhs
より小さい規模を持ちます。
var x = 22
x %= 5
// x == 2
var y = 22
y %= -5
// y == 2
var z = -22
z %= -5
// z == -2
Relationships 関係
From Protocol 由来プロトコル
See Also 参照
Arithmetic with Assignment 代入での算術
static func += (inout Int, Int)
Adds two values and stores the result in the left-hand-side variable.
2つの値を加算して、結果を左手側の変数に格納します。
static func *= (inout Int, Int)
Multiplies two values and stores the result in the left-hand-side variable.
2つの値を乗算して、結果を左手側の変数に格納します。
static func /= (inout Int, Int)
Divides the first value by the second and stores the quotient in the left-hand-side variable.
最初の値を2番目の値で除算して、商を左手側の変数に格納します。