# Swift NumberKit

## Overview

This is a macOS framework implementing advanced numeric data types for the Swift 4 programming language. The current version provides three new numeric types:

`BigInt`

: arbitrary-precision signed integers`Rational`

: signed rational numbers`Complex`

: complex floating-point numbers

**Requirements**:

- Xcode 9.3
- Swift 4.1
- Optional: Swift Package Manager

**Note**: So far, with every major version of Swift, Apple decided to change the foundational APIs of the numeric
types in Swift significantly and consistently in a backward incompatible way. In order to be more isolated from
such changes in future, I decided to introduce a distinct integer type used in NumberKit using a new protocol
`IntegerNumber`

. All standard numeric integer types implement this protocol. This is now consistent with the
usage of protocol `FloatingPointNumber`

for floating point numbers, where there was, so far, never a good,
generic enough foundation (and still isn't). Unfortunately, this is a change that might break some client usage
of NumberKit. Adaptations should be straightforward.

## BigInt

`BigInt`

objects are immutable, signed, arbitrary-precision integers that can be used as a
drop-in replacement for the existing binary integer types of Swift 4. Struct `BigInt`

defines all
the standard arithmetic integer operations and implements the corresponding protocols defined
in the standard library.

## Rational

Struct `Rational<T>`

defines immutable, rational numbers based on an existing signed integer
type `T`

, like `Int32`

, `Int64`

, or `BigInt`

. A rational number is a signed number that can
be expressed as the quotient of two integers *a* and *b*: *a / b*.

## Complex

Struct `Complex<T>`

defines complex numbers based on an existing floating point type `T`

,
like `Float`

or `Double`

. A complex number consists of two components, a real part *re*
and an imaginary part *im* and is typically written as: *re + im * i* where *i* is
the *imaginary unit*.

## Github

link |

Stars: 22 |

##### Help us keep the lights on

## Dependencies

## Releases

## 2.2.0 - Mar 30, 2018

- Migrated library to Xcode 9.3
- Ported code to Swift 4.1

## 2.1.0 - Jan 24, 2018

- Comprehensive support for bit operations on
`BigInt`

numbers - Several bug fixes for existing bit operations

## 2.0.5 - Jan 17, 2018

- Fixes serious bug in division and remainder logic for
`BigInt`

numbers - Support for bit counting (incl. counting leading and trailing zero bits)

## 2.0.4 - Nov 16, 2017

- Adapt to Swift 4.0.2
- Optimize performance of
`BigInt`

## 2.0.3 - Oct 15, 2017

Adopt SPM API Version 4.