pggimeno@wanadoo.es pggimeno@wanadoo.es
Wed, 18 Dec 2002 14:18:12 +0100

Sergey Misnik wrote:

>Can I operate with integers that are represented with 744 decimals (309=20
>bytes) at full precision (not as doubles with 18-20 decimal places)?

What is an integer with decimals?

Integer types are of mpz_t in GMP; float types of variable size (not
limited to 8-byte IEEE) are mpf_t. Look at these in the GMP manual.

>How can I use GMP in FreePascal or Delphi?

AFAIK nobody's written a GMP unitfor FPC or Delphi. However, writing
one for every GMP function should be quite straightforward; if you
need one, you may write it yourself. See for example <FPC installation
directory>/source/packages/zlib/zlib.pp or <Delphi installation
directory>\Source\Rtl\Win\LZExpand.pas; look at the functions which
have the keyword "external". You may also want to look for "external"
in Delphi's help or manual.

Note that the calling convention may depend on how GMP is compiled
(I'm not sure if it may be varied or what it is if not so) but you may
need to use one of the keywords "cdecl" or "stdcall" in the external
declarations. The examples I've mentioned use both.

Note also that it's possible to write a multi-platform and
multi-compiler unit by using just a few {$IFDEF...}; notably in
zlib.pp there's a constant called "libz" which is defined as the
string 'z' but might be used to select a DLL on Delphi (sorry, I've
not used external declarations in FPC, just in Delphi; I don't know
what the name is supposed to mean but I suspect that it is the
argument to the linker).

You may also want to take a look at FPC's h2pas. I've never tried it
but I suspect that it won't work very well with all the preprocessor
trickery inside gmp.h.

  Pedro Gimeno