Skip to content

rootmos/lua-bigint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

250 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lua-bigint

Tests

A small arbitrary precision integer Lua library, with a paranoid and extensive test suite using Haskell's native arbitrary precision integers, QuickCheck and HsLua.

Example

local I = require("bigint")

local a = I.fromstring("78840069980359889583804398923873743190317791505792283599345825435746711")
local b = I.fromstring("6952646245343968493900761108507")
local c = I.fromstring("-8177365527942")
local d = I.fromstring("364781755081040559817863568837659573725854950265808819869491980")
local f = 7319870

print((a - b - 1)//(c + 1) + (d % f))
-9641255452134745719230413362696917903840332893074689350422

Try it out

Download bigint.lua from the latest release and chuck it into Lua:

lua -l I=bigint -e 'print(I.build_info)'

Or grab the latest pre-release using gh

gh release download "$(gh release list --json tagName --jq '.[0].tagName')" --pattern bigint.lua

Or build from the source

./mk-dist && ls dist

Or use the development scripts

The run and repl scripts:

  • download and verify the Lua version specified in the deps/lua/lua.json file,
  • builds both 32 and 64 bit versions and select which depending on the LUA_BITS environment variable,
  • and adds the src directory to Lua's package.path.

About

A small arbitrary precision integer Lua library

Resources

Stars

Watchers

Forks

Contributors