[fpc-pascal] Re: Why this evaluates on "if" wrong ? (GMP)
Tom Verhoeff
T.Verhoeff at tue.nl
Mon Oct 29 21:09:39 CET 2007
On Mon, Oct 29, 2007 at 06:36:11PM +0100, Micha Nelissen wrote:
>
> It's possible to create a type that stores the numerator and
> denominator, but then you would need to "simplify" to extract common
> factors on every calculation, otherwise it would quickly run out of
> range (Integer or whatever you choose). Extracting common factors takes
> exponential time, so it's quite slow. The range would be quite limited
> as well, it's as wide as the numerator.
In fact, the GMP (GNU Multiple Precision Arithmetic Library <gmplib.org>)
offers this and more. Unfortunately, there does not seem to be a complete
FreePascal interface for it. Maybe it is easy to adapt (if necessary?)
the GNU Pascal interface for GMP <http://www.gnu-pascal.de/gpc/GMP.html>.
I would be interested.
There is also an initial attempt <http://fjf.gnu.de/misc/gmpop.inc>
to make the GMP functions available as operators under GNU Pascal.
The (ultimate) goal is that you can simply write things like
r := (a + b) * c where a, b, and c have a GMP number type,
instead of writing things like mpq_add ( r, a, b ) ; mpq_mul ( r, r, c ) .
Tom
--
E-MAIL: T.Verhoeff @ TUE.NL | Dept. of Math. & Comp. Science
PHONE: +31 40 247 41 25 | Technische Universiteit Eindhoven
FAX: +31 40 247 54 04 | PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/ | The Netherlands
More information about the fpc-pascal
mailing list