Large numbers in Pascal (Delphi)

陌路散爱 提交于 2019-11-27 03:52:43

问题


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


回答1:


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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/3590171/large-numbers-in-pascal-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!