Binding for GNU MP v5.1.2
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
.gitignore
LICENSE
README.md
gmp.lua

README.md

Features

  • Full support of 5.1.2 API (except low-level functions)

Example code

  local gmp = require 'gmp' ('libgmp-10')

  local mpz = gmp.types.z

  local a,b = mpz(), mpz()

  gmp.z_init_set_str(a, '39679054966380032223487239670184', 10)
  gmp.z_init_set_str(b, '85186439059104575627262464195387', 10)

  gmp.z_mul(a,a,b)

  gmp.printf('Result: %Zd\n', a)

  gmp.z_clears(a,b)

Differences from the C API

Binding is so close to the original API as possible, but some things still differ.

  1. Names lost 'gmp' prefix as not needed.
  2. f_get_d_2exp, f_get_str return exp as second result.
  3. Added luasprintf, for formatted output in lua string.

TODO

  • Wrap mpz_import and mpz_export functions