Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/public/core/Int128.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ extension _${U}Int128: FixedWidthInteger {
by rhs: Self
) -> (partialValue: Self, overflow: Bool) {
% if signed:
let isNegative = (self._isNegative != rhs._isNegative)
let isNegative = (self._isNegative != rhs._isNegative && self != .zero && rhs != .zero)
let (p, overflow) = self.magnitude.multipliedReportingOverflow(
by: rhs.magnitude)
let r = _Int128(bitPattern: isNegative ? p._twosComplement : p)
Expand All @@ -281,7 +281,7 @@ extension _${U}Int128: FixedWidthInteger {
by other: UInt64
) -> (partialValue: Self, overflow: Bool) {
% if signed:
let isNegative = self._isNegative
let isNegative = self._isNegative && self != .zero && other != .zero
let (p, overflow) = self.magnitude.multipliedReportingOverflow(by: other)
let r = _Int128(bitPattern: isNegative ? p._twosComplement : p)
return (r, overflow || (isNegative != r._isNegative))
Expand Down