Updated 2015-11-07 18:57:14 by RLE

Bignum, by Colin McCormack, is a critcl wrapper to libgmp.

See Also  edit

bignum in pure Tcl, by SS
Book Review: BigNum Math, by CL, 2006
Arbitrary-Precision Integers for Tcl 8.5 TIP #237
Big bitstring operations
Big Floating-Point Numbers
Big integer routines
big integer to floating enhancement to Tcl
BigFloat for Tcl
Bignums Fast and Dirty

Requirements  edit

libgmp3 >= 4.1.1
or similar under Linux; get it from any GNU archive (if you haven't got it). To recompile it, you'll need the latest version of critcl.

Installation  edit

Unpack in /usr/lib, /usr/local/lib, or wherever your tcl resides

Description  edit

Bignum provides the following packages:
which provides wrappers for arbitrary precision integers
which provides wrappers for arbitrary precision floats
both bigint and bigfloat

Of necessity, licensed under GPL, since libgmp is.

stevel 2005-01-27:

I've modified bignum to use the latest Critcl, and built a cross-platform library Starkit with binaries for Linux, Windows and OSX [1]

To use, either unpack the Starkit and copy the contents of the lib directory into somewere on your auto_path, or just source it directly
% source bignum.kit
% package require bignum
% bigint::add 1111111111111111111111111111 2222222222222222222222222222

The binaries on Windows and Linux are statically linked against libgmp (and therefore self-contained) but I couldn't get this working on OSX so you'll need to have gmp installed on your LDPATH to use bignum on OSX. I'll have another go later.

The modified source is available at [2]

LES 2005-07-27: Using bignum.kit from sdarchive with ActiveTcl 8.5 on Windows 98, I ran this command...
::bigint::powm 5 6 0

...and Tcl crashed (pure DOS or Tkcon). It only seems to happen with the 0, but it does happen every time. Maybe I shouldn't be using 0, I admit I do not understand what that function really does (I wanted to calculate a large number raised to a large power). But I don't think that Tcl or bignum should crash on me just because I threw a zero at it. :-)

Lars H: powm is probably "power modulo" (a very common operation in many cryptographical algorithms), so a zero as last argument is likely to lead to "divide by zero" conditions. This could either be a bug in libgmp, or a failure of the wrapper to catch input not supported by that library, but come Tcl 8.5 we'll most likely have equivalent functionality in the core anyway (happy, happy; joy, joy).