# 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.

• "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. Feb 11, 2012 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? Feb 11, 2012 at 13:34
• The book "Java Number Crunchers" might be of interest to you. The translation from Java to .NET should be easy. Feb 11, 2012 at 13:50
• "Knuth describes something is overcomplicated". False. It's exactly the right level of complication. This is not simple. Feb 12, 2012 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. Feb 12, 2012 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.