File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2294,7 +2294,7 @@ ${unsafeOperationComment(x.operator)}
2294
2294
2295
2295
@inline ( __always)
2296
2296
public init< T : BinaryInteger> ( extendingOrTruncating source: T) {
2297
- if Self . bitWidth <= ${ word_bits} || source . bitWidth <= $ { word_bits } {
2297
+ if Self . bitWidth <= ${ word_bits} {
2298
2298
self = Self . init ( _truncatingBits: source. _lowWord)
2299
2299
}
2300
2300
else {
Original file line number Diff line number Diff line change @@ -738,6 +738,18 @@ dwTests.test("inits") {
738
738
_ = DWU16 ( UInt32 . max)
739
739
}
740
740
741
+ dwTests. test ( " TwoWords " ) {
742
+ typealias DW = DoubleWidth < Int >
743
+
744
+ expectEqual ( - 1 as DW , DW ( extendingOrTruncating: - 1 as Int8 ) )
745
+
746
+ expectNil ( Int ( exactly: DW ( Int . min) - 1 ) )
747
+ expectNil ( Int ( exactly: DW ( Int . max) + 1 ) )
748
+
749
+ expectTrue ( DW ( Int . min) - 1 < Int . min)
750
+ expectTrue ( DW ( Int . max) + 1 > Int . max)
751
+ }
752
+
741
753
dwTests. test ( " Bitshifts " ) {
742
754
typealias DWU16 = DoubleWidth < UInt8 >
743
755
typealias DWU32 = DoubleWidth < DWU16 >
You can’t perform that action at this time.
0 commit comments