diff --git a/README.md b/README.md index 2863661f..3657a6a7 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,21 @@ let x = I32.random() #expect(x.hashValue == IXL(x).hashValue) ``` +#### Lone description coder + +You may need to convert binary integers to human-readable text. In that case, `description(using:)` and `init(_:using:)` let you perform dynamic radix conversions using the given coder. It uses a fixed number of non-generic and non-inlinable algorithms to encode and decode all binary integer types. + +##### MacBook Pro, 13-inch, M1, 2020, -O, code coverage disabled. + +```swift +let fib1e6 = IXL.fibonacci(1_000_000) // 0.015s +let fib1e6r10 = fib1e6.description(using: .decimal) // 0.297s (208988 digits) +let fib1e6r16 = fib1e6.description(using: .hexadecimal) // 0.002s (173561 digits) + +try IXL(fib1e6r10, using: .decimal) // 0.040s (208988 digits) +try IXL(fib1e6r16, using: .hexadecimal) // 0.002s (173561 digits) +``` + ### The `Fallible` redemption arc diff --git a/Tests/Benchmarks/Fibonacci.swift b/Tests/Benchmarks/Fibonacci.swift index eb5c7518..5e29e9e5 100644 --- a/Tests/Benchmarks/Fibonacci.swift +++ b/Tests/Benchmarks/Fibonacci.swift @@ -24,7 +24,7 @@ final class FibonacciBenchmarks: XCTestCase { // MARK: Metadata //=------------------------------------------------------------------------= - static let fib1e6 = IXL.fibonacci(1_000_000) + static let fib1e6 = IXL.fibonacci(1_000_000) static let fib1e6r10 = fib1e6.description(using: .decimal) static let fib1e6r16 = fib1e6.description(using: .hexadecimal)