Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jitsusama/uint128
A Swift 128-bit Unsigned Integer Data Type conforming to the UnsignedInteger Protocol
https://github.com/jitsusama/uint128
swift swift3 swift4 unsigned-integers
Last synced: about 1 month ago
JSON representation
A Swift 128-bit Unsigned Integer Data Type conforming to the UnsignedInteger Protocol
- Host: GitHub
- URL: https://github.com/jitsusama/uint128
- Owner: Jitsusama
- License: apache-2.0
- Created: 2016-01-30T23:43:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-02T14:45:47.000Z (about 1 year ago)
- Last Synced: 2024-10-12T14:22:50.039Z (about 1 month ago)
- Topics: swift, swift3, swift4, unsigned-integers
- Language: Swift
- Size: 380 KB
- Stars: 62
- Watchers: 8
- Forks: 24
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UInt128
A Swift 128-bit Unsigned Integer Data Type conforming to the UnsignedInteger,
FixedWidth, BinaryInteger, Hashable, Numeric, Equatable,
ExpressibleByIntegerLiteral, CustomStringConvertible, CustomDebugStringConvertible,
Comparable and Codable (thanks @adamnemecek) Protocols,
as well as extending the BinaryFloatingPoint and String types to support operating
with its new type.[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
## Installation
This library includes Carthage, CocoaPods and SPM support out of the box.
Reference this git repository in a Podfile, Cartfile or Package.swift file in
order to easily include this library while also being able to easily track
changes.You can also manually copy over the `Sources/UInt128.swift` file into your project
and it should work great. I've purposely kept this library constrained to a
single file in order to support this use case.## Usage
Since this library fully implements the UnsignedInteger protocol, you can use
this data type just like any other native UInt data type. For numbers larger
than UIntMax, you'll either want to call the `init(upperBits: UInt64, lowerBits:
UInt64)` initializer, or, use the `init(_ source: String)` initializer to
create an instance with a string. The string can be in binary, octal, decimal
or hexadecimal.For example:
let uInt128ByString = UInt128("0xffaabbcc00129823fa9a12d4aa87f498")!
let uInt128ByInteger: UInt128 = 1234## Building
This project includes an example Xcode project for building the framework that
also includes a playground that can be utilized for testing things out. This
Xcode project can build from one target a iphone, iphonesimulator or macos
build. It also includes unit testing and code coverage.