mfloat20

advertisement
MFLOAT Version 2.0
==================
for
BORLAND C++ 3.1
BORLAND C++ 4.0
TURBO PASCAL 6.0
BORLAND PASCAL 7.0
Brief description
=================
* MFLOAT handles arithmetic using high precision numbers of up to 77
decimal
digits.
* Programs written in C or C++ can use MFLOAT simply by replacing the
double data format with the MFLOAT data format. The operators and the
functions are overloaded for C++ and so only little changes of the
source
code are necessary. (You need BORLAND C++ 3.1). The language C++ is
recommended for MFLOAT.
* MFLOAT is optimised for maximum speed for high precision numbers. These
subroutines are the fastest for the 8086 microprocessor known to us. If
you
find faster subroutines for a 8086, please send an email.
* MFLOAT is able to use 80386 instructions to gain a speedup factor of
1.5-3
for some basic arithmetic operations.
* MFLOAT subroutines are much faster than a standard emulation of a
coprocessor for the same accuracy. MFLOAT does not use the coprocessor.
* MFLOAT is written in assembler for the 8086 microprocessor and
compatibles.
The calculation is 6 to 30 times faster than that of subroutines
written in
C or PASCAL for high precision numbers. This is important for tedious
calculations like an optimisation, where you have problems with the
accuracy. For this problems you can avoid the use of a super computer
using C or PASCAL routines for high precision numbers.
* All important functions of PASCAL and of a C library ("MATH.H") are
included. This includes the transcendental functions like sin(x),
atan(x),
exp(x), log(x)....
* All important functions for complex arithmetic of the C++ library
"COMPLEX.H" are included. This includes the transcendental functions
like
sin(x), atan(x), exp(x), log(x)....
* The subroutines are included in compiled form (object files) in a
program.
Therefore you can use them for PASCAL, C and C++. The subroutines are
tested for BORLAND PASCAL 7.0, TURBO PASCAL 6.0, BORLAND C++ 3.1 and
BORLAND C++ 4.0.
* This package is limited to about 77 decimal digits. You may license the
source code. Then you can extend the precision up to 5000 decimal
digits
(the upper limit is due to the memory limit of one segment of the
8086).
* The internal data format is a binary floating point format. The length
of
the mantissa can be chosen by the user from one word to 16 words.
(1 word = 16 bits). This corresponds to about 5, 10, 14, 19, 24, 29,
34,
39, 43, 48, 53, 58, 63, 67, 72 and 77 digits of a decimal number. One
word
represents 4.81648 digits of a decimal number in average. The exponent
of
two has the length of 16 bits. The largest representable number is
about
7.07E+9863, the smallest is about 7.07E-9865.
* For an interested user, most of the source code is included in this
package.
Files of MFLOAT
===============
READ.ME
CPP.DOC
C.DOC
PAS.DOC
EXAMPLES.DOC
MCOMPLEX.DOC
INTERNAL.DOC
TIME.DOC
REGISTER.DOC
MFLOATA.OBJ
MFLOATB.OBJ
MFLOAT.H
MF_CPP.H
MF_CPP.CPP
PFLOAT.PAS
BESSEL.CPP
DYNAMIC.CPP
-
general information (this file)
installation and description for the subroutines in C++
installation and description for the subroutines in C
installation and description for the subroutines in PASCAL
description of the examples
description of the complex arithmetic - used formulas
more information for the expert
timing information
information about registration
subroutines written in assembler
subroutines written in C
C header file
C++ header file
C++ classes "mfloat" and "mcomplex"
PASCAL unit: declarations of the external subroutines
example in C++, calculation of the Bessel function
example in C++, use of dynamic mfloat variables
EULER.CPP
GAMMA.CPP
PI.CPP
PIAGM.CPP
POLAR.CPP
BESSEL.C
DYNAMIC.C
EULER.C
GAMMA.C
PI.C
PIAGM.C
POLAR.C
BESSEL.PAS
DYNAMIC.PAS
EULER.PAS
GAMMA.PAS
PI.PAS
PIAGM.PAS
POLAR.PAS
coordinates
PI.EXE
MFLOATA.ASM
MFLOATB.C
MFLOATC.ASM
-
example
example
example
example
example
example
example
example
example
example
example
example
example
example
example
example
example
example
example
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
C++, calculation of Euler's constant
C++, calculation of the complex gamma function
C++, calculation of pi
C++, calculation of pi using AGM
C++, conversion Cartesian to polar coordinates
C, calculation of the Bessel function
C, use of dynamic mfloat variables
C, calculation of Euler's constant
C, calculation of the gamma function
C, calculation of pi
C, calculation of pi using AGM
C, conversion Cartesian to polar coordinates
PASCAL, calculation of the Bessel function
PASCAL, use of dynamic mfloat variables
PASCAL, calculation of Euler's constant
PASCAL, calculation of the gamma function
PASCAL, calculation of pi
PASCAL, calculation of pi using AGM
PASCAL, conversion Cartesian to polar
-
example program executable, calculation of pi
source code in assembler (only parts of the subroutines)
source code in C
source code in assembler (constants)
Multiple-precision Calculations using MFLOAT
============================================
MFLOAT is a package of subroutines written in assembler for a 8086 microprocessor or compatibles. It is made for users having problems with the
accuracy of standard IEEE arithmetic.
The precision of IEEE-754 standard floating point numbers is good enough
for most technical and scientific applications. But sometimes a scientist
or a mathematician has problems in his calculations because the algorithm
or
the mathematical problem is very ill-conditioned (for example finding the
roots of a polynomial). As the floating point numbers are only
approximations
of real or rational numbers, there is an additional error at every
floating
point operation.
There is no method known to represent every real number exactly in a
binary format and therefore an approximation is necessary. A practical
method
is to extend the mantissa of the floating point number, which results in
less error at every operation. But there are limitations because of
higher
memory needs for every floating point number and increased execution
time.
This is why a scientist having numerical problems of this kind is looking
for very fast subroutines for multiple-precision floating point numbers.
This package represents such a package of subroutines. It uses a binary
data format because there are optimal instructions for the manipulation
of
binary numbers in the instruction-set of the 8086 and 80386. A binary
data
format has also the advantage, that the used memory is minimised. The
only
disadvantage is the higher effort that is necessary for the input and
output
of the numbers in ASCII-Format.
The main goal is a minimal computing time for very accurate numbers.
Therefore no time is wasted for rounding (every result is truncated) and
the handling of abnormal numbers as NANs or denormals. The only special
number is zero.
In case of an overflow or some other calculation error an error-flag
(variable "calcuationerror") is set, which can be tested during or at the
end of the calculation. Of course in such a case the numerical result is
wrong. For the development of the a program using mfloat, the program can
also be interrupted at an error, if you set another flag
("useInterruptAtError=1"). At the screen you see an error message
indicating
the error. (For example "MFLOAT error: division by zero"):
In case of an underflow the result is set to zero without any message.
There is a very large range for the exponent. The greatest number, that
can
by represented, is about +/-7.07E+9863, the smallest is about +/-7.07E9865.
To avoid much time for searching terrible error of stack overflows, a
stacktest is included in the assembler procedures.
What is new, since MFLOAT version 1.0 ?
=======================================
* MFLOAT is faster now, if you have a 80386 processor or a compatible
one.
It uses 80386 instruction, if you set the char variable
"use386instructions" to some value but not zero (see also
"mfloatTest80386()"). The gain factor is about 1.5-3 for
multiplications,
but only, if you use an even number of mantissa-words. For detailed
information see the file "TIME.DOC".
* MFLOAT helps the user to find runtime errors. If you set the char
variable
"useInterruptAtError" to one, the program terminates at a runtime error
and an error message is written to the screen. Therefore you can find a
runtime error using a debugger much easier.
* The problem of crashes
in the assembler part.
language. For C++ this
"compact", "large" and
due to stack overflow is solved by a stack check
This check is independent of the programming
stack check is correct for the memory models
"huge".
* For better understanding the program package, the source code of the
subroutines are included ("MFLOATA.ASM","MFLOATB.C" and "MFLOATC.ASM"),
for assembler only some parts.
* MFLOAT includes subroutines for the calculation of complex arithmetic
for
C++ in the files "MF_CPP.H" and "MF_CPP.CPP".
* There is a constructor for string constants: for example: a="1.4345"
* There is a new procedure "powi".
* There is a new procedure "inttomf".
* Some more examples are added to the package.
* The maximum precision is now 16 mantissa-words or 77 digits.
* The registration procedure of MFLOAT has changed now (see file
"REGISTER.DOC").
* MFLOAT includes most of the source code (assembler sources code not
completely).
Installation
============
C.DOC
CPP.DOC
PAS.DOC
... description for "C" programs
... description for "C++" programs
... description for "PASCAL" programs
Examples
========
Some examples using MFLOAT are included by this package. They are
interesting from the point of view of numerical analysis. If you have an
interesting example or you know a new or a better formula for some
function,
or you have a faster method, send an email. I am interested in it.
The authors of MFLOAT are interested in the feedback of the users of
MFLOAT.
If you have problems or you find some bugs (the subroutines are checked
very
thoroughly, but the probability, that a software of large dimension has
no
bug is not high in reality), please describe them and send a mail. You
help
us to remove these errors of the subroutines.
Many thanks for your help and much success with MFLOAT.
MFLOAT is shareware. Registration: see file "REGISTER.DOC".
Kaufmann Friedrich & Mueller Walter
Technical University of Graz
Download