{"id":19385785,"url":"https://github.com/oscbyspro/numberick","last_synced_at":"2025-08-16T09:07:08.728Z","repository":{"id":170018202,"uuid":"638969916","full_name":"oscbyspro/Numberick","owner":"oscbyspro","description":"An arithmagick overhaul in Swift","archived":false,"fork":false,"pushed_at":"2024-06-04T04:09:07.000Z","size":5247,"stargazers_count":15,"open_issues_count":14,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-12T16:44:25.953Z","etag":null,"topics":["arbitrary-precision","arithmagick","bigint","fixed-width","integers","overhaul","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oscbyspro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-10T13:37:52.000Z","updated_at":"2025-03-30T12:24:27.000Z","dependencies_parsed_at":"2024-05-04T08:25:02.167Z","dependency_job_id":"f0db8dd9-cf23-4df7-bf23-35b3fa3d5e95","html_url":"https://github.com/oscbyspro/Numberick","commit_stats":null,"previous_names":["oscbyspro/numberick"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/oscbyspro/Numberick","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscbyspro%2FNumberick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscbyspro%2FNumberick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscbyspro%2FNumberick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscbyspro%2FNumberick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oscbyspro","download_url":"https://codeload.github.com/oscbyspro/Numberick/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oscbyspro%2FNumberick/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270689907,"owners_count":24628762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrary-precision","arithmagick","bigint","fixed-width","integers","overhaul","swift","swift-package-manager"],"created_at":"2024-11-10T10:03:05.297Z","updated_at":"2025-08-16T09:07:08.692Z","avatar_url":"https://github.com/oscbyspro.png","language":"Swift","readme":"# [Numberick][NBK/D]\n\n✨ An arithmagick overhaul in Swift.\n\n| Package | Swift | iOS   | Mac Catalyst | macOS | tvOS  | watchOS |\n|:-------:|:-----:|:-----:|:------------:|:-----:|:-----:|:-------:|\n| 0.17.0  | 5.7   | 14.0  | 14.0         | 11.0  | 14.0  | 7.0     |\n\n\u003e [!IMPORTANT]\n\u003e The development of this project has moved over to [**Ultimathnum**](https://github.com/oscbyspro/Ultimathnum).\n \n\u003e It turns out that I need \\~(\\~(x)) to equal x for all x.\\\n\u003e This is not possible with arbitrary unsigned integers at the moment.\\\n\u003e So I'm working on a novel abstraction that permits this.\\\n\u003e It unifies all sizes and brings recovery mechanisms to generic code.\\\n\u003e Also, I'm open to work.\n\n## Table of Contents\n\n* [NBKCoreKit](#nbkcorekit)\n* [NBKDoubleWidthKit](#nbkdoublewidthkit)\n* [NBKFlexibleWidthKit](#nbkflexiblewidthkit)\n* [Installation](#installation)\n* [Acknowledgements](#acknowledgements)\n\n\u003ca name=\"nbkcorekit\"/\u003e\n\n## NBKCoreKit ([Sources][COR/S], [Tests][COR/T], [Benchmarks][COR/B])\n\nA new protocol hierarchy that refines Swift's standard library.\n\n### Protocols\n\n- [NBKBinaryInteger](Sources/NBKCoreKit/NBKBinaryInteger.swift)\n- [NBKBitPatternConvertible](Sources/NBKCoreKit/NBKBitPatternConvertible.swift)\n- [NBKCoreInteger](Sources/NBKCoreKit/NBKCoreInteger.swift)\n- [NBKFixedWidthInteger](Sources/NBKCoreKit/NBKFixedWidthInteger.swift)\n- [NBKSignedInteger](Sources/NBKCoreKit/NBKSignedInteger.swift)\n- [NBKUnsignedInteger](Sources/NBKCoreKit/NBKUnsignedInteger.swift)\n\n### Models\n\n- [NBKChunkedInt](Sources/NBKCoreKit/Models/NBKChunkedInt.swift)\n- [NBKEndianness](Sources/NBKCoreKit/Models/NBKEndianness.swift)\n- [NBKPrimeSieve](Sources/NBKCoreKit/Models/NBKPrimeSieve.swift)\n- [NBKStaticBigInt](Sources/NBKCoreKit/Models/NBKStaticBigInt.swift)\n\n\u003ca name=\"nbkdoublewidthkit\"/\u003e\n\n## [NBKDoubleWidthKit][DBL/D] ([Sources][DBL/S], [Tests][DBL/T], [Benchmarks][DBL/B])\n\nA composable, large, fixed-width, two's complement, binary integer.\n\n### 🧩 Composable\n\n``NBKDoubleWidth`` is a generic software model for working with fixed-width\nintegers larger than one machine word. Its bit width is double the bit width of\nits `High` component. In this way, you may construct new integer types:\n\n```swift\ntypealias  Int256 = NBKDoubleWidth\u003c Int128\u003e\ntypealias UInt256 = NBKDoubleWidth\u003cUInt128\u003e\n```\n\n### 💕 Two's Complement\n\nLike other binary integers, ``NBKDoubleWidth`` has two's complement semantics. \n\n```\nThe two's complement representation of  0 is an infinite sequence of 0s.\nThe two's complement representation of -1 is an infinite sequence of 1s.\n```\n\n### 🏰 Fixed-Width Integer\n\nEach ``NBKDoubleWidth`` has a fixed bit width, and so do its halves. \nThis design comes with a suite of overflow and bit-casting operations. \nThe even split also lends itself to divide-and-conquer strategies.\n\n### 📖 Trivial UInt Collection\n\n``NBKDoubleWidth`` models a trivial `UInt` collection, where `UInt` is an\nunsigned machine word. It contains at least two words, but the exact count\ndepends on the platform's architecture. You should, therefore, use\nproperties like `startIndex` and `endIndex` instead of hard-coded indices.\n\n```\n// Int256 and UInt256, as constructed on a 64-bit platform:\n┌───────────────────────────┐ ┌───────────────────────────┐\n│           Int256          │ │          UInt256          │\n├─────────────┬─────────────┤ ├─────────────┬─────────────┤\n│    Int128   │   UInt128   │ │   UInt128   │   UInt128   │\n├──────┬──────┼──────┬──────┤ ├──────┬──────┼──────┬──────┤\n│  Int │ UInt │ UInt │ UInt │ │ UInt │ UInt │ UInt │ UInt │\n└──────┴──────┴──────┴──────┘ └──────┴──────┴──────┴──────┘\n```\n\nSwift's type system enforces proper layout insofar as `Int` and `UInt` are the\nonly types in the standard library that meet its type requirements. \nSpecifically, only `Int` and `UInt` have `NBKCoreInteger\u003cUInt\u003e` `Digit` types.\n\n### 🚀 Single Digit Arithmagick\n\nAlongside its ordinary arithmagick operations, ``NBKDoubleWidth`` provides\nsingle-digit operations, where a digit is an un/signed machine word. These\noperations are more efficient for small calculations. Here are some examples:\n\n```swift\nInt256(1) + Int(1), UInt256(1) + UInt(1)\nInt256(2) - Int(2), UInt256(2) - UInt(2)\nInt256(3) * Int(3), UInt256(3) * UInt(3)\nInt256(4) / Int(4), UInt256(4) / UInt(4)\nInt256(5) % Int(5), UInt256(5) % UInt(5)\n```\n\n\u003ca name=\"nbkflexiblewidthkit\"/\u003e\n\n## [NBKFlexibleWidthKit][FLX/D] ([Sources][FLX/S], [Tests][FLX/T], [Benchmarks][FLX/B])\n\n\u003e [!IMPORTANT]\n\u003e It's a work in progress. I may rework it at any time.\n\n### Models\n\n- [NBKFibonacciXL](Sources/NBKFlexibleWidthKit/Models/NBKFibonacciXL.swift)\n- [UIntXL](Sources/NBKFlexibleWidthKit/NBKFlexibleWidth.swift)\n\n### Fibonacci\n\n```swift\nNBKFibonacciXL(0) // (index: 0, element: 0, next: 1)\nNBKFibonacciXL(1) // (index: 1, element: 1, next: 1)\nNBKFibonacciXL(2) // (index: 2, element: 1, next: 2)\nNBKFibonacciXL(3) // (index: 3, element: 2, next: 3)\nNBKFibonacciXL(4) // (index: 4, element: 3, next: 5)\nNBKFibonacciXL(5) // (index: 5, element: 5, next: 8)\n```\n\nIt uses a fast double-and-add algorithm:\n\n```swift\nNBKFibonacciXL(10_000_000) // 2.3s on MacBook Pro, 13-inch, M1, 2020\n```\n\nBut you can also step through it manually:\n\n```swift\nmutating func increment() { ... } // index + 1\nmutating func decrement() { ... } // index - 1\nmutating func    double() { ... } // index * 2\n```\n\n\u003ca name=\"installation\"/\u003e\n\n## Installation\n\nNumberick contains several modules. Import some or all of them.\n\n### [SemVer 2.0.0](https://semver.org)\n\n\u003e Major version zero (0.y.z) is for initial development.\n\u003e\n\u003e Anything MAY change at any time. \n\u003e\n\u003e The public API SHOULD NOT be considered stable.\n\n### Using [SwiftPM](https://swift.org/package-manager)\n\nAdd this package to your list of package dependencies.\n\n```swift\n.package(url: \"https://github.com/oscbyspro/Numberick.git\", .upToNextMinor(from: \"0.17.0\")),\n```\n\nChoose target dependencies from the products in [Package.swift](Package.swift).\n\n```swift\n.product(name: \"Numberick\",           package: \"Numberick\"),\n.product(name: \"NBKCoreKit\",          package: \"Numberick\"),\n.product(name: \"NBKDoubleWidthKit\",   package: \"Numberick\"),\n.product(name: \"NBKFlexibleWidthKit\", package: \"Numberick\"),\n```\n\n### Using [CocoaPods](http://cocoapods.org)\n\nChoose target dependencies from the pods listed in the root directory.\n\n```rb\npod \"Numberick\",                   \"~\u003e 0.17.0\"\npod \"Numberick-NBKCoreKit\",        \"~\u003e 0.17.0\"\npod \"Numberick-NBKDoubleWidthKit\", \"~\u003e 0.17.0\"\n```\n\n\u003ca name=\"acknowledgements\"/\u003e\n\n## Acknowledgements\n\nThis project is inspired by [**Int128**][Apple/Int128] and [**DoubleWidth**][Apple/DoubleWidth] by Apple.\n\n\u003c!-- Links --\u003e\n\n[NBK/D]: https://oscbyspro.github.io/Numberick/documentation/numberick\n[DBL/D]: https://oscbyspro.github.io/Numberick/documentation/numberick/nbkdoublewidth\n[FLX/D]: https://oscbyspro.github.io/Numberick/documentation/numberick/nbkflexiblewidth\n[SIG/D]: https://oscbyspro.github.io/Numberick/documentation/numberick/nbksigned\n\n[COR/S]: Sources/NBKCoreKit\n[DBL/S]: Sources/NBKDoubleWidthKit\n[FLX/S]: Sources/NBKFlexibleWidthKit\n\n[COR/T]: Tests/NBKCoreKitTests\n[DBL/T]: Tests/NBKDoubleWidthKitTests\n[FLX/T]: Tests/NBKFlexibleWidthKitTests\n\n[COR/B]: Tests/NBKCoreKitBenchmarks\n[DBL/B]: Tests/NBKDoubleWidthKitBenchmarks\n[FLX/B]: Tests/NBKFlexibleWidthKitBenchmarks\n\n\u003c!-- Links x Miscellaneous --\u003e\n\n[Apple/Int128]: https://github.com/apple/swift/blob/main/stdlib/public/core/Int128.swift.gyb\n[Apple/DoubleWidth]: https://github.com/apple/swift/blob/main/test/Prototypes/DoubleWidth.swift.gyb\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscbyspro%2Fnumberick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foscbyspro%2Fnumberick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foscbyspro%2Fnumberick/lists"}