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 e5fb871 commit 237d877Copy full SHA for 237d877
stdlib/public/core/Integers.swift.gyb
@@ -3373,10 +3373,11 @@ public struct DoubleWidth<Base : FixedWidthInteger> :
3373
let result = DoubleWidth(extendingOrTruncating: product)
3374
3375
let isNegative = (self < 0) != (rhs < 0)
3376
- let overflow = isNegative
3377
- ? carry != ~0
3378
- : carry != 0
3379
- return (result, ArithmeticOverflow(overflow))
+ let didCarry = isNegative ? carry != ~0 : carry != 0
+ let hadPositiveOverflow = !isNegative &&
+ DoubleWidth.isSigned && product.leadingZeroBitCount == 0
+
3380
+ return (result, ArithmeticOverflow(didCarry || hadPositiveOverflow))
3381
}
3382
3383
public func quotientAndRemainder(dividingBy other: DoubleWidth)
0 commit comments