• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created about 11 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go language interface to GMP - GNU Multiprecision Library (golang)

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

More Repositories

1

stressdisk

Stress test your disks / memory cards / USB sticks before trusting your valuable data to them
Go
320
star
2

swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
Go
313
star
3

directio

This is library for the Go language to enable use of Direct IO under all OSes
Go
298
star
4

gotemplate

Package based templating system for Go
Go
258
star
5

go-nflog-acctd

IP accounting using NFLOG under Linux iptables
Go
53
star
6

oauthproxy

This is an oauth2 proxy server
Go
34
star
7

johnroids

Johnroids is an old style asteroids game implemented in go, gopherjs and go/wasm
Go
29
star
8

dropbox

Go (golang) client library for the Dropbox core and Datastore API with support for uploading and downloading encrypted files.
Go
11
star
9

go-deadlocks-talk

Sample code for my Go Deadlocks talk
Go
9
star
10

make_test_files

A program to generate test files
Go
8
star
11

fsyncbench

Benchmark fsync
Go
8
star
12

fetch-actions-logs

Fetch your GitHub Actions logs
Go
8
star
13

iprime

All integer Mersenne prime checker
C++
7
star
14

oxo3d

Oxo3d - 3D noughts and crosses / tic tac toe
Go
6
star
15

ioccc2012

Mersenne prime prover for IOCCC 2012
C
6
star
16

mirror

Neopixel based Infinity Mirror running on Raspbery Pi Pico-W with Micropython
Python
5
star
17

snake-puzzle

A solver for the Snake Puzzle using python with a Jupyter notebook
Jupyter Notebook
5
star
18

rcloneguiexperiment

Rclone GUI experiment
JavaScript
5
star
19

pwhash

Mirror of antihe.ro/pwhash
Go
5
star
20

pslq

Go (golang) library and cli tool for using the PSLQ integer relation algorithm.
Go
3
star
21

mandelterm

View Mandelbrot sets in your terminal
Go
3
star
22

www

Nick Craig-Wood's Website
Python
2
star
23

router-rebooter

Reboots your Netgear DG834 ADSL router when the internet connection drops
Python
2
star
24

parse-actions-logs

Parse GitHub actions logs for go test results
Go
2
star
25

.github

Default community health files for ncw
1
star
26

rclone-archive

Archive of old rclone branches
Go
1
star
27

euler_bbp

Programs and paper to demonstrate Euler's BBP-type formulae for pi
TeX
1
star