操作符
&-(_:
&-(_:_:)
返回两个给定值的差,包装结果以防溢出。
声明
static func &- (lhs: Self, rhs: Self) -> Self
参数
lhs
一个数值。
rhs
要从
lhs
中减去的值。
详述
溢出减法运算符 (&-
) 丢弃任何溢出整数类型的固定宽度的位。在下面的例子中,10
和21
的差值小于零,即UInt
的最小可表示值,所以结果是丢弃溢出位后的部分值。
let x: UInt8 = 21 &- 10
// x == 11
let y: UInt8 = 10 &- 21
// y == 245 (after overflow)
有关使用溢出运算符的算术的更多信息,请参阅 The Swift Programming Language
中的 Overflow Operators。
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相关用法
- Swift UInt8 &-=(_:_:)用法及代码示例
- Swift UInt8 &<<(_:_:)用法及代码示例
- Swift UInt8 &=(_:_:)用法及代码示例
- Swift UInt8 &(_:_:)用法及代码示例
- Swift UInt8 &*(_:_:)用法及代码示例
- Swift UInt8 &*=(_:_:)用法及代码示例
- Swift UInt8 &>>=(_:_:)用法及代码示例
- Swift UInt8 &+(_:_:)用法及代码示例
- Swift UInt8 &+=(_:_:)用法及代码示例
- Swift UInt8 &<<=(_:_:)用法及代码示例
- Swift UInt8 &>>(_:_:)用法及代码示例
- Swift UInt8 ~(_:)用法及代码示例
- Swift UInt8 leadingZeroBitCount用法及代码示例
- Swift UInt8 init(integerLiteral:)用法及代码示例
- Swift UInt8 ..<(_:_:)用法及代码示例
- Swift UInt8 *=(_:_:)用法及代码示例
- Swift UInt8 multipliedFullWidth(by:)用法及代码示例
- Swift UInt8 ^=(_:_:)用法及代码示例
- Swift UInt8 init(clamping:)用法及代码示例
- Swift UInt8 init(truncatingIfNeeded:)用法及代码示例
- Swift UInt8 *(_:_:)用法及代码示例
- Swift UInt8 trailingZeroBitCount用法及代码示例
- Swift UInt8 +(_:)用法及代码示例
- Swift UInt8 >>=(_:_:)用法及代码示例
- Swift UInt8 >>(_:_:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 UInt8 &-(_:_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。