[test/Prototypes] Fix DoubleWidth think-os #70289
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Aligns the implementation with fixes already committed in the apple/swift-numerics repository:
Since it turns out there's more than one calling site for
_divide
that doesn't ensure the invariant asserted on line 598, we should actually deal with this in one place by replacing the assertion with a guard that handles the special case.Additionally, fix another think-o related to full-width multiplication where a carry isn't accounted for, causing unintended overflow with certain inputs.
This type now gives correct output verified for addition/subtraction/multiplication/nonzero-division-with-overflow for every pair of 16-bit unsigned integers using
DoubleWidth<DoubleWidth<UInt4>>
(with a customUInt4
implementation).Resolves apple/swift-numerics#272.