Compose extremely large integers using BigInteger in C# .NET

Exercises in .NET with Andras Nemes

The largest integer that can be stored in a long, i.e. a 64-bit integer is 9,223,372,036,854,775,807 in .NET. That is a very large number that will be enough for most applications out there.

However, sometimes it’s not enough and you need to handle something larger. This article on Wikipedia shows several use cases where this can occur. .NET also provides the float and double numeric types that provide much larger ranges. They won’t be integers exactly but they may suit your needs anyhow.

The .NET framework has an object called BigInteger that lets you construct arbitrarily large integers. This object resides in the System.Numerics namespace so you’ll need to reference the System.Numerics.dll library.

View original post 78 more words

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.