Instance Method インスタンスメソッド

isMultiple(of:)

Returns true if this value is a multiple of the given value, and false otherwise. trueをもしこの値がその与えられた値の倍数ならば、そしてfalseをそうでないならば返します。

Declaration 宣言

func isMultiple(of other: UInt8) -> Bool

Parameters パラメータ

other

The value to test. テストする値。

Discussion 解説

For two integers a and b, a is a multiple of b if there exists a third integer q such that a = q*b. For example, 6 is a multiple of 3 because 6 = 2*3. Zero is a multiple of everything because 0 = 0*x for any integer x. 2つの整数abに対して、abの倍数です、もし第3の整数qが存在して、a = q*bであるようなところでは。例えば、63の倍数です、なぜなら6 = 2*3なので。ゼロはあらゆるものの倍数です、なぜなら0 = 0*xなので、どんな整数xに対してもです。

Two edge cases are worth particular attention: 2つの境界事例は特別な注意を払う価値があります:

  • x.isMultiple(of: 0) is true if x is zero and false otherwise. x.isMultiple(of: 0)trueです、もしxがゼロであるならば、そしてそうでなければfalseです。

  • T.min.isMultiple(of: -1) is true for signed integer T, even though the quotient T.min / -1 isn’t representable in type T. T.min.isMultiple(of: -1)trueです、符号付き整数Tに対して、たとえ商T.min / -1が型Tで表現可能でなくてさえ。