Version 2 of Bignums Fast and Dirty

Updated 2004-01-28 10:43:43

I had a need the other day for dealing with some really big numbers. Unfortunately, the machine I was using did not have mpexpr installed. Woe is me. Until I came up with the following fast and very dirty workaround. Works on Unix systems and Windows systems with Cygwin:

 proc mpexpr { args } {
  return [ exec echo $args | bc -l ]
 }

 % mpexpr 12342342354564636*94852304570297207525
 1170699616126044020647089347918085900

Is it a cheat? Well, yeah, it's a cheat. But it was darn handy!

CMcC I've written bignum, a quick critcl wrapper for libgmp, giving arbitrary precision ints and floats.

Sarnold I have written a little library for multiple precision arithmetics, in pure Tcl : see MPA. It should be cross-platform, although I have tested it only on Windows with ActiveTcl.

DKF: Time to learn a bit more exec magic:

  proc mpexpr args {
     exec bc -l <<[join $args]
  }

Category Mathematics