DCSIMG
BigInteger in .NET 4.0 - Pavel's Blog
Sign in | Join | Help

Pavel's Blog

Pavel is a software guy that is interested in almost everything
software related... way too much for too little time

BigInteger in .NET 4.0

One of the simplest new additions to the .NET 4.0 framework is an integer with arbitrary length, System.Numerics.BigInteger. Here’s a simple usage example, comparing it to a double:

 

BigInteger b = BigInteger.Pow(2, 64);

Console.WriteLine("BigInteger: {0}", b.ToString("N"));

Console.WriteLine("Double:     {0}", Math.Pow(2, 64).ToString("N"));

Console.WriteLine();

b = BigInteger.Pow(2, 128);

Console.WriteLine("BigInteger: {0}", b.ToString("N"));

Console.WriteLine("Double:     {0}", ((double)b).ToString("N"));

The output is:

image

Not bad.

Comments List

# The Return (Appearance) of the Complex Type

Published at Tuesday, October 27, 2009 6:13 PM by Pavel's Blog  

Early in the ads for .NET 4.0, there were rumours about two types dealing with numeric stuff, BigInteger

Leave a Comment

(required) 
(
required
)
 
(optional)
(required) 

Enter the numbers above: