Re: [fpc-pascal] Super Large Integer Math Calculations

2017-07-08 Thread Ingemar Ragnemalm


Bart  wrote:


On 7/7/17, nore...@z505.com  wrote:


For integers beyond 64 bit, or even beyond 32 bit on a 64 bit machine,
why can't the math be broken down into peices the way a human does it on
paper, and then theoretically any number can be added and subtracted,
even if it is beyond 32/64 bit?

Example:

type TSuperLargeInt = string;

var
i, j: TSuperLargeInt;
output: TSuperLargeInt;
begin
i := '10009';
j := '10001';
output := AddLargeInts(i,j);
writeln(output);
end.

http://svn.code.sf.net/p/flyingsheep/code/trunk/wtf/ncalc.pp does exactly that
(all dependenies are also found at
http://svn.code.sf.net/p/flyingsheep/code/trunk/wtf).

It can handle integers (and only integers) up to 2GB digits with
absolut precision.
It can handle GoogolPlex.

Calculate 9^99 with absolute precision:
29512665430652752148753480226197736314359272517043832886063884637676943433478020332709411004889

Fac(100)?
9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864

It's not lightning fast, but there is room for optimization I guess.

Bart


Great! I knew someone must have made that! I needed this a few months 
ago, but resorted to Python at that time. Now I can use FPC next time. :)


/Ingemar

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Food for thought - language string improvement

2017-07-08 Thread Felipe Monteiro de Carvalho
> Language features like this is what increases productivity.

Indeed {$INCLUDESTRINGFILE file} looks like a great solution for this.

Since we are talking about language features, after learning Java I
think we could use in Pascal:

1> Default methods in interfaces (implementation multiple-inheritance,
would be extremely useful in Lazarus)

2> Try with resources like in Java

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal