Giter Club home page Giter Club logo

biginteger's Introduction

BigInteger.swift

BigInteger.swift is a lightweight library that facilitates an easy way to work with big integers in Swift. Built on top of LibTomMath C library. Inspired by the Java's BigInteger, but a lot of syntactic sugar added.

Example

import BigInteger

var a = BigInteger("111111111111111111111111111111111111111111111110000000001")!
var b = 999_999_999
var c = a + b // 111111111111111111111111111111111111111111111111000000000

c -= BigInteger("11111111111111111111111111111111111111111111111000000000")!
// 100000000000000000000000000000000000000000000000000000000

c = (c / 1000000000000000000)!
// 10000000000000000000000000000000000000000000000000

c = BigInteger(2).pow(120) // 1329227995784915872903807060280344576

c >>= 116 // 16

c = BigInteger(1) << 120 // 1329227995784915872903807060280344576

c = (c % 1000)! // 576

let result = c.divideAndRemainder(50)
result!.quotient // 11
result!.reminder // 26

Features

  • Addition, subraction, multiplication, division and reminder
  • Bitwise and, or, xor, shift left, shift right
  • Negate, abs, gcd
  • Comparisions

Requirements

  • iOS 7.0+ / Mac OS X 10.9+
  • Xcode 6.1

Installation

The same you install any popular Swift framework, for example, Alamofire, SQLite.swift.

Author

biginteger's People

Contributors

kirsteins avatar mmizutani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

biginteger's Issues

Swift 3

It's moments like these how little I know about Swift. I've downloaded the latest version and tried to convert it to current syntax and usage, but I'm not having any luck. (For example: Invalid redeclaration of 'asString()'; Redundant conformance of 'Big Integer' to protocol 'Equatable')

Are you still supporting this very nice implementation?

Kia ora,
Laurie

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.