实例方法
quotient
quotientAndRemainder(dividingBy:)
返回此值除以给定值的商和余数。
声明
func quotientAndRemainder(dividingBy rhs: Self) -> (quotient: Self, remainder: Self)
返回值
包含此值除以 rhs
的商和余数的元组。
参数
rhs
将此值除以的值。
详述
使用此方法同时计算除法的商和余数。
let x = 1_000_000
let (q, r) = x.quotientAndRemainder(dividingBy: 933)
// q == 1071
// r == 757
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相关用法
- Swift Int32 <<=(_:_:)用法及代码示例
- Swift Int32 &=(_:_:)用法及代码示例
- Swift Int32 &<<=(_:_:)用法及代码示例
- Swift Int32 ...(_:_:)用法及代码示例
- Swift Int32 negate()用法及代码示例
- Swift Int32 multipliedFullWidth(by:)用法及代码示例
- Swift Int32 init(integerLiteral:)用法及代码示例
- Swift Int32 &(_:_:)用法及代码示例
- Swift Int32 init(truncatingIfNeeded:)用法及代码示例
- Swift Int32 +=(_:_:)用法及代码示例
- Swift Int32 init(_:radix:)用法及代码示例
- Swift Int32 &+(_:_:)用法及代码示例
- Swift Int32 !=(_:_:)用法及代码示例
- Swift Int32 -(_:)用法及代码示例
- Swift Int32 init(clamping:)用法及代码示例
- Swift Int32 ..<(_:_:)用法及代码示例
- Swift Int32 -=(_:_:)用法及代码示例
- Swift Int32 %(_:_:)用法及代码示例
- Swift Int32 <<(_:_:)用法及代码示例
- Swift Int32 init(_:)用法及代码示例
- Swift Int32 trailingZeroBitCount用法及代码示例
- Swift Int32 >>(_:_:)用法及代码示例
- Swift Int32 &>>(_:_:)用法及代码示例
- Swift Int32 -(_:_:)用法及代码示例
- Swift Int32 &>>=(_:_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Int32 quotientAndRemainder(dividingBy:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。