Back to Home Page
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
- MATHEMATICA (Wolfson Co home page) - very ($900) expensive - students $140
- MAPLE (Waterloo Maple home page) - less ($500) expensive - students $130
- UBASIC - free - down-loadable - for Intel type processors with DOS or Windows9x
- 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
- JAVA Decimal arithmetic for Java[TM] courtesy Mike Cowlishaw, IBM Fellow
- 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)
- The last stable version of UBASIC of which I am aware is version 8.8f (7 October 2000), available as a zipfile at < http://www.trnicely.net/misc/ubver88f.zip >.
- 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.
- 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.
- responses to questions about arrays with more than 10^6 elements
- Ultraprecision integer arithmetic is available in C through use of the GMP libraries; see < http://gmplib.org >. Ultraprecision floating-point arithmetic is available through the MPFR libraries; see < http://www.mpfr.org >. 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).
- UBASIC is a BASIC interpreter with multiprecision arithmetic.
It can run on DOS or the DOS window of Win95 and WinNT.
- UB*.EXE and UBCONST7.DAT are the minimal set of files to run.
- UBASIC is a free software.
- UBASIC is freely distributable.
- UBASIC is written by Yuji KIDA at Rikkyo University in Japan.
You can contact the author via e-mail( email@example.com ) (no longer valid?).
An archive site for UBASIC is Math Archives Spotted by Thomas R. Nicely
Local copy of ub874.zip
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
- see UBASIC (extended precision) above
- http://www.freebasic.net/, a nice 32 bit BASIC compilier resembling MS-QuickBASIC, that adds new features such as pointers, unsigned data types, inline-assembly and many others. For a nice (free) user interface/editor/debugger, I use http://www.radasm.com/fbedit/
- not so standard XBasic http://www.maxreason.com/software/xbasic/xbasic.html
Back to Home Page
Updated August 2008