Long integers_(re)

Mon, 30 Jun 1997 13:05:50 +0200 (MET DST)


According to Frank Heckenbach:
> 
> Thinking about it, it might be better to implement long integers as a
> schema or object type (perhaps with PXSC operators?)...

I have heared of a library "gmp" which could be a useful tool to
achieve this.  Just write a Pascal interface for it ...

> BTW: Is there any information about schema types and/or PXSC available?
> I don't know more about them than I saw in some examples.

So do I.  :-(

> If I know more about them, it could be relatively easy to implement them...

Think of a schema as a type declaration with parameters which can occur
anywhere in the declared type: as array or subrange boundaries, or as a
variant record selector.  (I am not sure if the latter one really works.)

For PXSC, it's even easier because operators are the only PXSC thing so far
implemented in GPC.  Procedure overloading will be the next one.  And there
is yet another syntax to define Modules (aka Units) which would probably be
easy to implement if I really know how it looks like.

> var x:array[1..10] of word;
> 
> begin
>   x:=8932740732465987432659087423658294376597843265987432659786;
>      {fill this number into x (according to endianness, "0-padded" for
>       positive numbers, "F-padded" for negative ones)}

I doubt whether this is really useful.  Numbers of this size aren't usually
typed in as decimal digits, but they are characterized as "2 pow 103 - 2 pow
97 + 3 pow 13".  And you can always write a function which accepts a string
or a chain of integers or whatever and returns a long number.

> Would this be possible to do? The latter instruction seems more difficult.
> "+" and "=" could be operators, implemented in Pascal. The requirement to
> the compiler would be to convert such numbers into an array (and a length
> value) automatically. Seems difficult, but since it's just like with
> strings, I hope it's possible...

Then the compiler would have to use this arbitrary-precision library (gmp?)
by itself because a number must be multiplied by ten each time a digit is
read.

Greetings,

    Peter

 Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970624] - http://home.pages.de/~gnu-pascal/ [970125]


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es