This package performs arbitrary precision integer arithmetic. It is a functional approach to arbitrary precision integers.
Most of the methods are recursive methods
with just a single switch
statement.
It contains one main enumeration: BinaryInteger
.
Binary
is just a linked list. It is a linked list whose elements are ones and zeros and the tail is either .empty(.postive)
or .empty(.negative)
.
The positive
one indicates an infinite stream of zeros whereas the negative
one indicates an infinite stream of ones.
It represents an arbitrary precision integer. It supports positive powers, addition, subtraction, multiplications, division, and modulus.
I'm a big fan of functional programming because it feels so mathematical. I was inspired to create this repository when I was reading through this book and translating the examples from Standard ML into Swift.