Giter Club home page Giter Club logo

swift-numberkit's Introduction

Swift NumberKit

Platform: macOS Language: Swift 4.0 IDE: Xcode 9.0 License: Apache

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:

  1. BigInt: arbitrary-precision signed integers
  2. Rational: signed rational numbers
  3. Complex: complex floating-point numbers

Requirements: Xcode 9/Swift Package Manager, Swift 4

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.

swift-numberkit's People

Contributors

objecthub avatar dankogai avatar thsoft avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.