Project Description

The BigNumber project is a testbed for developing various implementations of big integers and rational numbers in C#. The main guideline of the project is simplicity of use, robustness and completness of the libraries. The library will provide various algorithms for general use.

Full Description

This project started a long time ago and was written in many languages. There were versions in Pascal, C, C++ and Delphi. This is the latest reincarnation written in C# and I thought I should make it public.
The project started in .NET 1 and has since moved to .NET 2 and 3 (3.5) but I am not actually using any features from 3 so it compiles well in .NET 2. Also there are some remnants from the .NET 1 era that I will try to remove as I go along so be patient.

The main goals of this library are :

  • Simplicity of use – You can use the classes of the library the same way you would use Int32 (just don't forget this is a class and not a struct).
  • Robustness – You always get the correct result if you use the library correctly. And that there are no weird crashes, exceptions and restrictions.
  • Completeness – You have a complete set of satellite functionality like you would get with the .NET framework.

You should notice that this library does not concentrate (for now) on speeding up the calculations. If you want a really fast library you should visit . You might need to wrap it up a little but it works great and really fast.

In the future I intend to extend the library with more complex implementations that may give some improvement in speed. One of which is the Factoring big number.

How to use

Currently (in the test version) the best class to use would be StdBigNumber. In general the guideline is that any further implementation would have to be compatible with the StdBigNumber (I.e. convert to and from) and StdBigNumber is compatible with String. You also have some basic functionality as static functions of the StdBigNumber class.

I solved problem 53 on ( using this library in the most naive way. Here is my code. Note that StdBigNumber can be used just like, and together with int variables (if yo cast a number that is too long for an int you will get an OverflowException)

      List<StdBigNumber> factorials = new List<StdBigNumber>();
      for (StdBigNumber i = 0; i <= 100; i++)
      int sum = 0;
      for (StdBigNumber n = 1; n <= 100; n++)
        for (StdBigNumber r = 1; r <= n; r++)
          StdBigNumber Cnr = factorials[n] / (factorials[r] * factorials[n - r]);
          if (Cnr > 1000000)

I hope you enjoy using this library and will comment and suggest ideas in the forum.

Boris “ZBZZN” Kozorovitzky

Last edited Apr 13, 2009 at 11:48 AM by ZBZZN, version 6