TinyBigInt
Overview
A Big Ints library written in pure Swift 4.
This project provides integer types of arbitrary width implemented in 100% pure Swift.
Now only one integer type is included - BigUInt
. It is the Swift struct with copy-on-write value semantics, and it can be used much like any other integer type.
The library provides implementations for the most useful functions on big integers, including:
-
All functionality of
Comparable
andHashable
-
ALL arithmetic operators:
+
,-
,*
,/
,%
,+=
,-=
,*=
,/=
,%=
-
Bitwise operators:
~
,|
,&
,^
,|=
,&=
,^=
, plus the following read-only properties: -
width
: the minimum number of bits required to store the integer, -
trailingZeroBitCount
: the number of trailing zero bits in the binary representation, -
leadingZeroBitCount
: the number of leading zero bits (when the last digit isn't full), -
Shift operators:
>>
,<<
,>>=
,<<=
-
Radix conversion to/from
String
s and big integers.
The library needs to be 100% unit test coveraged.
License
TinyBigInt can be used, distributed and modified under the MIT license.
Requirements and Integration
TinyBigInt 1.0.0 requires Swift 4.
BigInt deploys to macOS 10.10, iOS 9, watchOS 2 and tvOS 9.
Setup instructions:
-
Swift Package Manager: Although the Package Manager is still in its infancy, BigInt provides experimental support for it. Add this to the dependency section of your
Package.swift
manifest:.Package(url: "https://github.com/matterinc/TinyBigInt.git", from: "1.0.0")
-
CocoaPods: Put this in your
Podfile
:pod 'TinyBigInt', '~> 1.0'