diff --git a/Sources/ANKFoundation/ANKBigEndianTextCodable.swift b/Sources/ANKFoundation/ANKBigEndianTextCodable.swift index 9502f210..ac2635c7 100644 --- a/Sources/ANKFoundation/ANKBigEndianTextCodable.swift +++ b/Sources/ANKFoundation/ANKBigEndianTextCodable.swift @@ -11,14 +11,14 @@ // MARK: * ANK x Binary Integer x Big Endian Text Codable //*============================================================================* -/// An integer type than can be decoded from and encoded to big endian text. +/// An integer type than can be converted to and from big-endian text. /// -/// - `Decode` big endian text with ``init(decoding:radix:)``. -/// - `Encode` big endian text with `String.init(encoding:radix:uppercase:)`. +/// - `Decode` big-endian text with ``init(decoding:radix:)``. +/// - `Encode` big-endian text with `String.init(encoding:radix:uppercase:)`. /// /// - Note: The `BinaryInteger` protocol in the standard library does not provide /// customization points for its binary integer coding methods. Converting to -/// and from big endian text happens to be particularly well suited for machine +/// and from big-endian text happens to be particularly well suited for machine /// word arithmetic, however, so these methods were added instead. /// public protocol ANKBigEndianTextCodable { diff --git a/Sources/ANKFullWidthKit/ANKFullWidth+Arithmetic.swift b/Sources/ANKFullWidthKit/ANKFullWidth+Arithmetic.swift index f0b9988f..81c17604 100644 --- a/Sources/ANKFullWidthKit/ANKFullWidth+Arithmetic.swift +++ b/Sources/ANKFullWidthKit/ANKFullWidth+Arithmetic.swift @@ -17,8 +17,11 @@ extension ANKFullWidth { // MARK: Utilities //=------------------------------------------------------------------------= + /// The absolute value of the remainder of dividing this value by its bit width. + /// /// - Returns: `abs(self % Self.bitWidth)` - @inlinable var absoluteValueModuloBitWidth: Int { + /// + @inlinable var moduloBitWidth: Int { //=--------------------------------------= if Self.bitWidth.isPowerOf2 { return Int(bitPattern: self.first) & (Self.bitWidth &- 1) diff --git a/Sources/ANKFullWidthKit/ANKFullWidth+Division.swift b/Sources/ANKFullWidthKit/ANKFullWidth+Division.swift index 4b363cac..299ecb7e 100644 --- a/Sources/ANKFullWidthKit/ANKFullWidth+Division.swift +++ b/Sources/ANKFullWidthKit/ANKFullWidth+Division.swift @@ -199,7 +199,7 @@ extension ANKFullWidth where High == High.Magnitude { let increment = Plus1(descending: HL(UInt(), divisor._bitshiftedLeft(words: quotientIndex, bits: Int()))) var approximation = Plus1(descending: increment.low.multipliedFullWidth(by: digit) as HL) //=------------------------------= - // Decrement When Overestimated + // Decrement If Overestimated //=------------------------------= if approximation > remainder { brrrrrrrrrrrrrrrrrrrrrrr: do { digit &-= 1; approximation &-= increment } diff --git a/Sources/ANKFullWidthKit/ANKFullWidth+Shifts.swift b/Sources/ANKFullWidthKit/ANKFullWidth+Shifts.swift index 1260d73d..ff253aed 100644 --- a/Sources/ANKFullWidthKit/ANKFullWidth+Shifts.swift +++ b/Sources/ANKFullWidthKit/ANKFullWidth+Shifts.swift @@ -20,7 +20,7 @@ extension ANKFullWidth { //=------------------------------------------------------------------------= @inlinable public static func &<<=(lhs: inout Self, rhs: Self) { - lhs._bitshiftLeft(by: rhs.absoluteValueModuloBitWidth) + lhs._bitshiftLeft(by: rhs.moduloBitWidth) } @_transparent public static func &<<(lhs: Self, rhs: Self) -> Self { @@ -105,7 +105,7 @@ extension ANKFullWidth { //=------------------------------------------------------------------------= @inlinable public static func &>>=(lhs: inout Self, rhs: Self) { - lhs._bitshiftRight(by: rhs.absoluteValueModuloBitWidth) + lhs._bitshiftRight(by: rhs.moduloBitWidth) } @_transparent public static func &>>(lhs: Self, rhs: Self) -> Self { diff --git a/Sources/ANKFullWidthKit/ANKFullWidth+Words.swift b/Sources/ANKFullWidthKit/ANKFullWidth+Words.swift index f5e60a68..9c02cc86 100644 --- a/Sources/ANKFullWidthKit/ANKFullWidth+Words.swift +++ b/Sources/ANKFullWidthKit/ANKFullWidth+Words.swift @@ -50,6 +50,20 @@ extension ANKFullWidth { @inlinable public var trailingZeroBitCount: Int { self.low.isZero ? Low.bitWidth &+ self.high.trailingZeroBitCount : self.low.trailingZeroBitCount } + + //=------------------------------------------------------------------------= + // MARK: Accessors + //=------------------------------------------------------------------------= + + /// The least significant word of this value. + /// + /// This is a top-secret™ requirement of [BinaryInteger][]. + /// + /// []: https://github.com/apple/swift/blob/main/stdlib/public/core/Integers.swift + /// + @_transparent public var _lowWord: UInt { + self.low._lowWord + } } //=----------------------------------------------------------------------------= diff --git a/Tests/ANKFullWidthKitBenchmarks/192+Complements.swift b/Tests/ANKFullWidthKitBenchmarks/192+Complements.swift index 0fd10c98..493f8cea 100644 --- a/Tests/ANKFullWidthKitBenchmarks/192+Complements.swift +++ b/Tests/ANKFullWidthKitBenchmarks/192+Complements.swift @@ -21,7 +21,7 @@ private typealias Y = ANK192X32 final class Int192BenchmarksOnComplements: XCTestCase { - typealias T = ANKInt192 + typealias T = ANKInt192 typealias M = ANKUInt192 //=------------------------------------------------------------------------= diff --git a/Tests/ANKFullWidthKitTests/128.swift b/Tests/ANKFullWidthKitTests/128.swift index 0deca204..50f1b35e 100644 --- a/Tests/ANKFullWidthKitTests/128.swift +++ b/Tests/ANKFullWidthKitTests/128.swift @@ -173,7 +173,7 @@ final class UInt128Tests: XCTestCase { func testInitAscending() { XCTAssertEqual(T(ascending: (ANKUInt64(1), ANKUInt64(2))), T(x64: X(1, 2))) } - + func testInitDescending() { XCTAssertEqual(T(descending: (ANKUInt64(2), ANKUInt64(1))), T(x64: X(1, 2))) } diff --git a/Tests/ANKFullWidthKitTests/192+Collection.swift b/Tests/ANKFullWidthKitTests/192+Collection.swift index e24945e3..e0d81ea2 100644 --- a/Tests/ANKFullWidthKitTests/192+Collection.swift +++ b/Tests/ANKFullWidthKitTests/192+Collection.swift @@ -48,9 +48,9 @@ final class Int192TestsOnCollection: XCTestCase { x0.withUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x0, x1) } @@ -60,14 +60,14 @@ final class Int192TestsOnCollection: XCTestCase { let y0 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0x00 }) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0x00 }) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) }; XCTAssertEqual(x0, y0) let y1 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x1, y1) } @@ -96,9 +96,9 @@ final class Int192TestsOnCollection: XCTestCase { x0.withUnsafeMutableWords { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } @@ -144,9 +144,9 @@ final class Int192TestsOnCollection: XCTestCase { x0.withContiguousMutableStorageIfAvailable { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } } @@ -184,9 +184,9 @@ final class UInt192TestsOnCollection: XCTestCase { x0.withUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x0, x1) } @@ -196,14 +196,14 @@ final class UInt192TestsOnCollection: XCTestCase { let y0 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0x00 }) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0x00 }) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) }; XCTAssertEqual(x0, y0) let y1 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x1, y1) } @@ -232,9 +232,9 @@ final class UInt192TestsOnCollection: XCTestCase { x0.withUnsafeMutableWords { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } @@ -280,9 +280,9 @@ final class UInt192TestsOnCollection: XCTestCase { x0.withContiguousMutableStorageIfAvailable { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } } diff --git a/Tests/ANKFullWidthKitTests/192+Text.swift b/Tests/ANKFullWidthKitTests/192+Text.swift index cd8e7009..0a5d300f 100644 --- a/Tests/ANKFullWidthKitTests/192+Text.swift +++ b/Tests/ANKFullWidthKitTests/192+Text.swift @@ -78,10 +78,10 @@ final class Int192TestsOnText: XCTestCase { XCTAssertEqual( "0o1234567012345670", T( 0o1234567012345670 as Int64)) XCTAssertEqual( "0b1010101010101010", T( 0b1010101010101010 as Int64)) - XCTAssertEqual("+1234567890", T(+1234567890 as Int64)) - XCTAssertEqual("+0x123456789abcdef0", T(+0x123456789abcdef0 as Int64)) - XCTAssertEqual("+0o1234567012345670", T(+0o1234567012345670 as Int64)) - XCTAssertEqual("+0b1010101010101010", T(+0b1010101010101010 as Int64)) + XCTAssertEqual("+1234567890", T( 1234567890 as Int64)) + XCTAssertEqual("+0x123456789abcdef0", T( 0x123456789abcdef0 as Int64)) + XCTAssertEqual("+0o1234567012345670", T( 0o1234567012345670 as Int64)) + XCTAssertEqual("+0b1010101010101010", T( 0b1010101010101010 as Int64)) XCTAssertEqual("-1234567890", T(-1234567890 as Int64)) XCTAssertEqual("-0x123456789abcdef0", T(-0x123456789abcdef0 as Int64)) @@ -213,15 +213,15 @@ final class UInt192TestsOnText: XCTestCase { } func testDecodingStringsWithOrWithoutSignAndRadixLiteral() { - XCTAssertEqual( "1234567890", T( 1234567890 as UInt64)) - XCTAssertEqual( "0x123456789abcdef0", T( 0x123456789abcdef0 as UInt64)) - XCTAssertEqual( "0o1234567012345670", T( 0o1234567012345670 as UInt64)) - XCTAssertEqual( "0b1010101010101010", T( 0b1010101010101010 as UInt64)) + XCTAssertEqual( "1234567890", T(1234567890 as UInt64)) + XCTAssertEqual( "0x123456789abcdef0", T(0x123456789abcdef0 as UInt64)) + XCTAssertEqual( "0o1234567012345670", T(0o1234567012345670 as UInt64)) + XCTAssertEqual( "0b1010101010101010", T(0b1010101010101010 as UInt64)) - XCTAssertEqual("+1234567890", T(+1234567890 as UInt64)) - XCTAssertEqual("+0x123456789abcdef0", T(+0x123456789abcdef0 as UInt64)) - XCTAssertEqual("+0o1234567012345670", T(+0o1234567012345670 as UInt64)) - XCTAssertEqual("+0b1010101010101010", T(+0b1010101010101010 as UInt64)) + XCTAssertEqual("+1234567890", T(1234567890 as UInt64)) + XCTAssertEqual("+0x123456789abcdef0", T(0x123456789abcdef0 as UInt64)) + XCTAssertEqual("+0o1234567012345670", T(0o1234567012345670 as UInt64)) + XCTAssertEqual("+0b1010101010101010", T(0b1010101010101010 as UInt64)) } func testDecodingPrefixingZerosHasNoEffect() { diff --git a/Tests/ANKFullWidthKitTests/256+Addition.swift b/Tests/ANKFullWidthKitTests/256+Addition.swift index 96d000a8..fed69309 100644 --- a/Tests/ANKFullWidthKitTests/256+Addition.swift +++ b/Tests/ANKFullWidthKitTests/256+Addition.swift @@ -190,11 +190,11 @@ final class UInt256TestsOnAddition: XCTestCase { XCTAssertEqual(T(0) + UInt(0), T(0)) XCTAssertEqual(T(0) + UInt(1), T(1)) XCTAssertEqual(T(0) + UInt(2), T(2)) - + XCTAssertEqual(T(1) + UInt(0), T(1)) XCTAssertEqual(T(1) + UInt(1), T(2)) XCTAssertEqual(T(1) + UInt(2), T(3)) - + XCTAssertEqual(T(x64: X(~0, ~0, ~0, 0)) + UInt(3), T(x64: X(2, 0, 0, 1))) XCTAssertEqual(T(x64: X(~0, ~0, 0, 0)) + UInt(3), T(x64: X(2, 0, 1, 0))) XCTAssertEqual(T(x64: X(~0, 0, 0, 0)) + UInt(3), T(x64: X(2, 1, 0, 0))) diff --git a/Tests/ANKFullWidthKitTests/256+Collection.swift b/Tests/ANKFullWidthKitTests/256+Collection.swift index 9eb3ecdc..879b6135 100644 --- a/Tests/ANKFullWidthKitTests/256+Collection.swift +++ b/Tests/ANKFullWidthKitTests/256+Collection.swift @@ -48,9 +48,9 @@ final class Int256TestsOnCollection: XCTestCase { x0.withUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x0, x1) } @@ -60,14 +60,14 @@ final class Int256TestsOnCollection: XCTestCase { let y0 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0x00 }) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0x00 }) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) }; XCTAssertEqual(x0, y0) let y1 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x1, y1) } @@ -96,9 +96,9 @@ final class Int256TestsOnCollection: XCTestCase { x0.withUnsafeMutableWords { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } @@ -144,9 +144,9 @@ final class Int256TestsOnCollection: XCTestCase { x0.withContiguousMutableStorageIfAvailable { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } } @@ -184,9 +184,9 @@ final class UInt256TestsOnCollection: XCTestCase { x0.withUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x0, x1) } @@ -196,14 +196,14 @@ final class UInt256TestsOnCollection: XCTestCase { let y0 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0x00 }) - XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) + BYTES.indices.forEach({ BYTES[$0] = 0x00 }) + XCTAssert(BYTES.allSatisfy({ $0 == 0x00 })) }; XCTAssertEqual(x0, y0) let y1 = T.fromUnsafeMutableBytes { BYTES in XCTAssertEqual(BYTES.count, T.bitWidth/8) - BYTES.indices.forEach({ BYTES[$0] = 0xff }) - XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) + BYTES.indices.forEach({ BYTES[$0] = 0xff }) + XCTAssert(BYTES.allSatisfy({ $0 == 0xff })) }; XCTAssertEqual(x1, y1) } @@ -232,9 +232,9 @@ final class UInt256TestsOnCollection: XCTestCase { x0.withUnsafeMutableWords { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } @@ -280,9 +280,9 @@ final class UInt256TestsOnCollection: XCTestCase { x0.withContiguousMutableStorageIfAvailable { WORDS in XCTAssertEqual(WORDS.count, T.count) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) - WORDS.indices.forEach({ WORDS[$0] = UInt.max }) - XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.min })) + WORDS.indices.forEach({ WORDS[$0] = UInt.max }) + XCTAssert(WORDS.allSatisfy({ $0 == UInt.max })) }; XCTAssertEqual(x0, x1) } } diff --git a/Tests/ANKFullWidthKitTests/256+Text.swift b/Tests/ANKFullWidthKitTests/256+Text.swift index 43f4500d..a89fe258 100644 --- a/Tests/ANKFullWidthKitTests/256+Text.swift +++ b/Tests/ANKFullWidthKitTests/256+Text.swift @@ -78,10 +78,10 @@ final class Int256TestsOnText: XCTestCase { XCTAssertEqual( "0o1234567012345670", T( 0o1234567012345670 as Int64)) XCTAssertEqual( "0b1010101010101010", T( 0b1010101010101010 as Int64)) - XCTAssertEqual("+1234567890", T(+1234567890 as Int64)) - XCTAssertEqual("+0x123456789abcdef0", T(+0x123456789abcdef0 as Int64)) - XCTAssertEqual("+0o1234567012345670", T(+0o1234567012345670 as Int64)) - XCTAssertEqual("+0b1010101010101010", T(+0b1010101010101010 as Int64)) + XCTAssertEqual("+1234567890", T( 1234567890 as Int64)) + XCTAssertEqual("+0x123456789abcdef0", T( 0x123456789abcdef0 as Int64)) + XCTAssertEqual("+0o1234567012345670", T( 0o1234567012345670 as Int64)) + XCTAssertEqual("+0b1010101010101010", T( 0b1010101010101010 as Int64)) XCTAssertEqual("-1234567890", T(-1234567890 as Int64)) XCTAssertEqual("-0x123456789abcdef0", T(-0x123456789abcdef0 as Int64)) @@ -213,15 +213,15 @@ final class UInt256TestsOnText: XCTestCase { } func testDecodingStringsWithOrWithoutSignAndRadixLiteral() { - XCTAssertEqual( "1234567890", T( 1234567890 as UInt64)) - XCTAssertEqual( "0x123456789abcdef0", T( 0x123456789abcdef0 as UInt64)) - XCTAssertEqual( "0o1234567012345670", T( 0o1234567012345670 as UInt64)) - XCTAssertEqual( "0b1010101010101010", T( 0b1010101010101010 as UInt64)) + XCTAssertEqual( "1234567890", T(1234567890 as UInt64)) + XCTAssertEqual( "0x123456789abcdef0", T(0x123456789abcdef0 as UInt64)) + XCTAssertEqual( "0o1234567012345670", T(0o1234567012345670 as UInt64)) + XCTAssertEqual( "0b1010101010101010", T(0b1010101010101010 as UInt64)) - XCTAssertEqual("+1234567890", T(+1234567890 as UInt64)) - XCTAssertEqual("+0x123456789abcdef0", T(+0x123456789abcdef0 as UInt64)) - XCTAssertEqual("+0o1234567012345670", T(+0o1234567012345670 as UInt64)) - XCTAssertEqual("+0b1010101010101010", T(+0b1010101010101010 as UInt64)) + XCTAssertEqual("+1234567890", T(1234567890 as UInt64)) + XCTAssertEqual("+0x123456789abcdef0", T(0x123456789abcdef0 as UInt64)) + XCTAssertEqual("+0o1234567012345670", T(0o1234567012345670 as UInt64)) + XCTAssertEqual("+0b1010101010101010", T(0b1010101010101010 as UInt64)) } func testDecodingPrefixingZerosHasNoEffect() {