.NET 4.0 BigInteger support

The February release of Delphi Prism will include support for the new .NET 4.0 “BigInteger” type for all integer constants. BigInteger is a new class that let’s it’s users define an arbitrarily large integer. Using this new type for integer constants is simple in Delphi Prism:

var r :=6985743574365784365432758943759843265983427594356349776534765743928657843567843625437564392067452985674398563429;var y :=8574398256943285643296524390; Console.WriteLine(y); Console.WriteLine(r); y := r - y; Console.WriteLine(y);


8574398256943285643296524390 6985743574365784365432758943759843265983427594356349776534765743928657843567843625437564392067452985674398563429 6985743574365784365432758943759843265983427594356349776534765743928657843567843625428989993810509700031102039039

Any constant that does not fit the largest type supported ((U)Int64) will become a BigInteger, or fail compiling if the new type isn’t referenced. BigInteger acts and works like a regular integer type, although it has some extra operations, like GreatestCommonDivisor, Remainder, Pow(er) and conversions to and from regular integer types.

Carlo Kok

Read more posts by this author.