Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */
posts - 159, comments - 0, trackbacks - 0

My Links


Your host

This is me! This space is about Microsoft® .NET® and Microsoft® Visual Basic development. Enjoy! :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.

Microsoft MVP

My MVP Profile

I'm a VB!

Watch my interview in Seattle

My new book on VB 2015!

Pre-order VB 2015 Unleashed Pre-order my new book "Visual Basic 2015 Unleashed". Click for more info!

My new book on LightSwitch!

Visual Studio LightSwitch Unleashed My book "Visual Studio LightSwitch Unleashed" is available. Click the cover!

Your visits

Follow me on Twitter!

CodePlex download Download my open-source projects from CodePlex!

Article Categories


Post Categories

.NET Framework


Help Authoring

Microsoft & MSDN

Setup & Deployment

Visual Basic 2005/2008/2010

The BigInteger type with Visual Basic 2010

Among the new types provided by .NET Framework 4.0, available also in the current Beta 1, there is the new System.Numerics.BigInteger. Such object's purpose is representing a signed integer, arbitrarily large, meaning that it has neither minimum nor maximum values, as instead happens about other .NET value types. In fact BigInteger doesn't expose the MinValue and MaxValue properties. The one thing you need to take care about is the risk of overflows if the value becomes too large.


A few examples:


        'Creating an instance

        Dim myInt As New System.Numerics.BigInteger


        'It could store the minimum Short...

        myInt = Short.MinValue

        '...or the maximum Long as well

        myInt = Long.MaxValue


        'The constructor can receive arguments; Double is accepted

        Dim myInt2 As New System.Numerics.BigInteger(2589352.425)


        'We can use conversion types

        Dim aSingle As SingleCSng(1234.56)

        Dim myInt3 As System.Numerics.BigInteger = CType(aSingle, Numerics.BigInteger)


Such structure also offer some methods for performing arithmetic operations. IntelliSense will show you everything you can do, anyway I provide a couple of examples from which you can see some support for complex operations too:


        'Subtracting BigInteger

        Console.WriteLine(Numerics.BigInteger.Subtract(myInt, myInt3))

        'Base 10 logarithm



        Console.WriteLine(Numerics.BigInteger.Pow(myInt3, 2))


The official MSDN page is available here.



Print | posted on venerdì 7 agosto 2009 03:02 | Filed Under [ Visual Studio 2010 Visual Basic ]


No comments posted yet.

Post Comment

Please add 1 and 5 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET