BigInteger: Beyond 32-Bit and 64-Bit Integers

Introduced in .NET 4.0 to support various functional and dynamic languages, the BigInteger type provides unlimited-precision integral value math. Internally, it’s based on bit-vectors on which operations are done by turning those into basic math operations that the processor supports, including 32-bit and 64-bit arithmetic as well as bit-level operations. Luckily, all of this plumbing is nicely abstracted away from the user, and thanks to rich operator overloading the use of BigInteger is quite simple.

First of all, note that BigInteger lives outside the triad of BCL assemblies, namely in the System.Numerics assembly. The namespace listening to the same name as this assembly will have to be imported, ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.