Giter Site home page Giter Site logo

gmp's Introduction

Gmp

GoDoc Build Status

This package provides a drop in replacement for Go's built in math/big big integer package using the GNU Multiprecision Library (GMP).

GMP is very much faster than Go's math/big however it is an external C library with all the problems that entails (cgo, dependencies etc)

This library was made by taking the cgo example of wrapping GMP from the Go source and doing the following to it

  • Copying the implementation from misc/cgo/gmp/gmp.go
  • Copying the documentation from src/pkg/math/big/int.go
  • Additional implementation of missing methods
  • Bug fixes for existing implementations
  • Making it passes the test suite from src/pkg/math/big/int_test.go
  • Adding memory management
  • Fix problems on 32 bit platforms when using int64 values which don't fit into a C.long
  • Implementing Rat support making it pass src/pkg/math/big/rat_test.go

See here for package docs

Install

Use go to install the library

go get github.com/ncw/gmp

Usage

See here for full package docs

To use as in a drop in replacement for math/big, replace

import "math/big"

With

import big "github.com/ncw/gmp"

Features that aren't part of math/big are clearly marked and if you are using those, then I suggest you import as

import "github.com/ncw/gmp"

Testing

To run the tests use

go test github.com/ncw/gmp

The tests have been copied from the tests for the math/big library in the Go source and modified as little as possible so it should be 100% compatible.

Differences

Here are the differences between math/big and this package

  • Int.Bits and Int.SetBits not implemented
  • Rat.Num() and Rat.Denom() return a copy not a reference, so
  • If you want to set them use the new methods Rat.SetNum() and Rat.SetDenom()

License

As this contains a great deal of code copied from the Go source it is licenced identically to the Go source itself - see the LICENSE file for details.

Contact and support

The project website is at:

There you can file bug reports, ask for help or contribute patches.

Authors

Contributors

gmp's People

Contributors

ncw avatar gijsbers avatar golint-fixer 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.