Large numbers in Pascal (Delphi)
Asked Answered
S

3

14

Can I work with large numbers (more than 10^400) with built-in method in Delphi?

Seftton answered 28/8, 2010 at 9:11 Comment(1)
They won't ask this question if they ever used Pascal or Delphi. The question built-in arbitrary precision is very trivial and should be simply removed.Onepiece
J
15

Not built-in, but you might want to check out MPArith for arbitrary precision maths.

Jordison answered 28/8, 2010 at 9:23 Comment(2)
Glad to have been of assistance - enjoy your number crunching!Jordison
@HMcG - Thanks, hope they serve you well!Jordison
T
3

There is also a Delphi BigInt library on SourceForge . I haven't tried it however, but include for completeness.

Triune answered 29/8, 2010 at 2:26 Comment(0)
E
-1

You could implement your own large number routines using Delphi's operator overloading.

For example add, subtract, multiply and division.

Intel has also added new instructions for multiply and possibly also for division in their latest chip design to come out in the near future.

One of these instructions is called: mulx

Intel mentions multiple carry streams which would allow multiplication to be accelerated as well.

x86 already had subtract with borrow, and add with carry, so now these new instructions do more or less the same for long multiplication and division and such... there are two methods to do multiplication and by using both apperently this becomes possible.

In the future Delphi will probably support these new instructions as well which could make programming something like this extra interesting.

For now these 4 basic operations might take you somewhere... or perhaps nowhere.

It depends a bit on what you want to do.. what kind of math ? just basic math like add/sub/mul/div

Or more complex math like cosinus, sinus, tan, and all kinds of other math functionality.

As far as I know operator overloading is available for records... I can vaguely remember that it might have been added to classes as well but take a grain of salt with that for now.

Operator overloading used to have a bug when converting between types... but it's been solved in later delphi versions, so it should be good to go.

Emelinaemeline answered 7/6, 2014 at 2:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.