# What are the most known arbitrary precision arithmetic implementation approaches? [closed]

I'm going to write a class library for .NET which provide an implementation of arbitrary precision arithmetic for integer, rational and maybe complex numbers. What best known approaches should I become familiar with?

I tried to start with Knuth's TAOCP Vol.2 (Seminumerical Algorithms, Chapter 4 – Arithmetic) but it's too complicated. At least I couldn't get the ideas in a relatively short period of time.

## closed as too broad by user53019, user22815, user40980, durron597, amonOct 1 '15 at 17:20

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• "At least I couldn't get the ideas in a relatively short period of time". Not surprising. Keep working at it. It's not simple. There is no Royal Road. – S.Lott Feb 11 '12 at 13:27
• Sure. I agree. I mean that the way how Knuth describes something is overcomplicated. Maybe you can recommend me some other source of knowledge which is simpler in its explanations? – Igor Soloydenko Feb 11 '12 at 13:34
• The book "Java Number Crunchers" might be of interest to you. The translation from Java to .NET should be easy. – dmeister Feb 11 '12 at 13:50
• "Knuth describes something is overcomplicated". False. It's exactly the right level of complication. This is not simple. – S.Lott Feb 12 '12 at 17:20
• Arithmetic is simple to describe, but difficult to implement in an efficient way. You can always use a naive algorithm, but it won't necessarily be fast. – Robert Harvey Feb 12 '12 at 20:46

If you are using C# 4.0 or later, then you already have a BigInteger class. Starting from here and creating your own `Rational` class will save you a lot of time.
If you want to build everything yourself, then you will have to implement some complex algorithms, especially for multiplication. You could start with the naive multiplication algorithm that has time complexity `O(n²)`. A lot of other algorithms will depend on multiplication (division, modular exponentiation, gcd, square roots, etc.). If you have have everything working and a solid set of unit tests, then you can replace the naive multiplication algorithm for something like 3-way Toom-Cook multiplication or an even more advanced algorithm.