Results 1 to 5 of 5

Thread: Working with extremely large numbers.

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    1

    Working with extremely large numbers.

    Need some help with overflows and extremely large numbers.

    For example, to calculate this:

    (22 ^ 29) Mod 57

    Supposedly there is a way to get around overflows and do these calculations, but I can't find much online. Now, the person who said this was doing VBA in Excel and said that there was about 4 lines of code which could handle the overflow so it wouldn't happen.

    I can't figure out how, thought I would try a quick VB program, but even using the Decimal data type these numbers are just too large.

    Any ideas? Thanks!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Working with extremely large numbers.

    .NET 4.0 adds the BigInteger data type. You have to add a reference to System.Numerics.dll and then you can use it fairly much as you do other numeric types. Just note that a BigInteger will never be created automatically from other data types if they overflow. You would have to create a BigInteger value explicitly for the '22' value at least. The other conversions should occur automatically, with the final result being a BigInteger.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member
    Join Date
    May 2009
    Posts
    274

    Re: Working with extremely large numbers.

    I'm having problems with large numbers too. I'm used to using VBA and VB6 and there was always a data type called variant that would always get around an overflow. It's been taken out of VB2010 Express. What's the equivalent please?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Working with extremely large numbers.

    Quote Originally Posted by norman_bates View Post
    I'm having problems with large numbers too. I'm used to using VBA and VB6 and there was always a data type called variant that would always get around an overflow. It's been taken out of VB2010 Express. What's the equivalent please?
    It hasn't been taken out of VB 2010. It has never existed in VB.NET. If you've read my previous post then you know how to handle large numbers. That's the end of the story. VB.NET won't let you fudge like other versions of VB. You have to do what you mean and mean what you do, like real programming.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Working with extremely large numbers.

    Quote Originally Posted by jmcilhinney View Post
    You have to do what you mean and mean what you do, like real programming.
    Quote of the day? I think so...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width