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!
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.
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?
Re: Working with extremely large numbers.
Quote:
Originally Posted by
norman_bates
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.
Re: Working with extremely large numbers.
Quote:
Originally Posted by
jmcilhinney
You have to do what you mean and mean what you do, like real programming.
Quote of the day? I think so...