We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3e80f8d commit f8c155aCopy full SHA for f8c155a
stdlib/public/core/Bit.swift
@@ -96,10 +96,11 @@ public func < (lhs: Bit, rhs: Bit) -> Bool {
96
extension Bit : IntegerArithmeticType {
97
static func _withOverflow(intResult: Int, overflow: Bool) -> (Bit, overflow: Bool) {
98
if let bit = Bit(rawValue: intResult) {
99
- return (bit, overflow)
+ return (bit, overflow: overflow)
100
} else {
101
- let bitRaw = intResult > 0 ? intResult % 2 : intResult % 2 + 2
102
- return (Bit(rawValue: bitRaw)!, overflow: true)
+ let bitRaw = intResult % 2 + (intResult < 0 ? 2 : 0)
+ let bit = Bit(rawValue: bitRaw)!
103
+ return (bit, overflow: true)
104
}
105
106
0 commit comments