操作符
&+=(_:
&+=(_:_:)
添加两个值并将结果存储在左侧变量中,包装任何溢出。
声明
static func &+= (lhs: inout Self, rhs: Self)
参数
lhs
要添加的第一个值。
rhs
要添加的第二个值。
详述
屏蔽加法赋值运算符 (&+=
) 静默包装在操作期间发生的任何溢出。在下面的例子中,100
和121
之和大于最大可表示的Int8
值,所以结果是丢弃溢出位后的部分值。
var x: Int8 = 10
x &+= 21
// x == 31
var y: Int8 = 100
y &+= 121
// y == -35 (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 FixedWidthInteger &+(_:_:)用法及代码示例
- Swift FixedWidthInteger &-=(_:_:)用法及代码示例
- Swift FixedWidthInteger &<<=(_:_:)用法及代码示例
- Swift FixedWidthInteger &<<(_:_:)用法及代码示例
- Swift FixedWidthInteger &-(_:_:)用法及代码示例
- Swift FixedWidthInteger &*=(_:_:)用法及代码示例
- Swift FixedWidthInteger &>>=(_:_:)用法及代码示例
- Swift FixedWidthInteger &>>(_:_:)用法及代码示例
- Swift FixedWidthInteger &*(_:_:)用法及代码示例
- Swift FixedWidthInteger multipliedFullWidth(by:)用法及代码示例
- Swift FixedWidthInteger nonzeroBitCount用法及代码示例
- Swift FixedWidthInteger init(_:radix:)用法及代码示例
- Swift FixedWidthInteger random(in:)用法及代码示例
- Swift FixedWidthInteger dividingFullWidth(_:)用法及代码示例
- Swift FixedWidthInteger leadingZeroBitCount用法及代码示例
- Swift FixedWidthInteger random(in:using:)用法及代码示例
- Swift FixedWidthInteger用法及代码示例
- Swift FlattenSequence prefix(_:)用法及代码示例
- Swift Float -(_:)用法及代码示例
- Swift FlattenSequence max(by:)用法及代码示例
- Swift Float80 /(_:_:)用法及代码示例
- Swift Float ...(_:_:)用法及代码示例
- Swift FloatingPointRoundingRule.toNearestOrAwayFromZero用法及代码示例
- Swift Float16 ...(_:_:)用法及代码示例
- Swift FloatingPointRoundingRule.up用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 FixedWidthInteger &+=(_:_:)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。