Back to Home Page

Computational Tools

The Babbage Difference Engine # 2 uses 31 decimal digit counters/accumulators (the highest order digit is used for over-flow detection). Unfortunately, the usual arithmetic data types available in BASIC, FORTRAN, C, ... are limited to about 15 decimal digits of precision.

It is possible, by using rather complicated coding tricks to enable BASIC, FORTRAN, C, to provide greater precision, but these are cumbersome and error prone to code. Extended precision is the phrase often used for these tricks. Many examples of addition and subtraction extended precision can be found, some for extended precision multiplication, but division with extended precision divisors is indeed an interesting challenge.

Fortunately there are a number of software systems that can handle the 30 decimal digit Babbage computational precision with out excessive tricks

  1. MATHEMATICA (Wolfson Co home page) - very ($900) expensive - students $140
  2. MAPLE (Waterloo Maple home page) - less ($500) expensive - students $130
  3. UBASIC - free - down-loadable - for Intel type processors with DOS or Windows9x
  4. A number of others - free - that seem to be restricted to UNIX or LINUX.
    A good example is GMP from GNU. Spotted by LaFarr Stuart
  5. JAVA Decimal arithmetic for Java[TM] courtesy Mike Cowlishaw, IBM Fellow
  6. PERL 5.005 with BIGFLOAT - free, but maybe not ready for prime time
    (The news group comp.lang.perl.modules seems to have its share of folks having trouble with declaring high precision variables and arrays to type Math::BigFloat - and passing them successfully to subroutines.)

Although I offer some examples using MATHEMATICA, I figure that most viewers may prefer the simplicity and cost of UBASIC

UBASIC for IBM-PC version 8.8f
Thomas R. Nicely writes (1 August 2008)
  1. The last stable version of UBASIC of which I am aware is version 8.8f (7 October 2000), available as a zipfile at < >.

  2. The last beta version of which I am aware is version 9.0zh ( 20 February 2001 ), but I found it riddled with bugs and backward incompatibilities, so I do not use it.

  3. The last beta version of which I am aware is version 9.0zh (20 February 2001), but I found it riddled with bugs and backward incompatibilities, so I do not use it.

  4. responses to questions about arrays with more than 10^6 elements

  5. Ultraprecision integer arithmetic is available in C through use of the GMP libraries; see < >. Ultraprecision floating-point arithmetic is available through the MPFR libraries; see < >. The C code (I also see little advantage in C++) will outperform UBASIC, but not by as much as you would think (perhaps one order of magnitude); Kida's code is amazingly good. However, UBASIC running inside DOSBox will be yet another order of magnitude slower (due to the emulation layer).

  1. UBASIC is a BASIC interpreter with multiprecision arithmetic.
    It can run on DOS or the DOS window of Win95 and WinNT.
  2. UB*.EXE and UBCONST7.DAT are the minimal set of files to run.
  3. UBASIC is a free software.
  4. UBASIC is freely distributable.
  5. UBASIC is written by Yuji KIDA at Rikkyo University in Japan.
    You can contact the author via e-mail( ) (no longer valid?).

An archive site for UBASIC is
Math Archives Spotted by Thomas R. Nicely
Local copy of
And here is an HTMLized help file I adapted from UBASIC documentation.

Probably a better, or easier to read, text is now on-line mega net

UBASIC is not as slick (editing is by line number) as some other BASIC versions, but it does allow precision many times larger than the approximately 15 bit precision of the IEEE floating point format used in most other implementations.

NOTE: Unless you place statements such as

10 word 30
20 point 20
at the beginning of your UBASIC program, you will not get added precision.

Sites that offer free basic

Some free math packages

Back to Home Page
Updated August 2008