开发者

Large numbers in Pascal (Delphi)

Can I 开发者_JAVA百科work with large numbers (more than 10^400) with built-in method in Delphi?


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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜