Search code examples
pythonvb.netvisual-studiooverflowexception

Overflow errors converting Python program to VB .NET


How are you?

In order to make the program I am working on more user-friendly and easier to deploy on Windows machines, I am in the process of converting an algorithm from Python (which works wonders) to VB .NET.

In this order:
-> Fetching decimal from data sheets (Excel, CSV, XML...)
-> Conversion to binary (string)
-> Binary manipulation / appending
-> Inversion (first char becomes last)
-> Conversion to signed integer for additional math
-> Final conversion to Hexadecimal (targeting a car ECU implementation)

However, this algorithm does huge number conversions (we are talking 1.0E100+), and while everything is done seamlessly in Python thanks to the variables auto assignment, etc., I can't seem to manipulate them on VB .NET due to their size, causing OverflowExceptions all the time.

So far, I know the biggest variables available in VB .NET are Decimal and UInt64, but they definitely don't suit my needs.

I also know that I can bypass the OverflowException checking in Visual Studio, but what would be the downsides? What leads/ideas/solutions would you suggest me? Is there any way to manipulate these kinds of numbers just like I did in Python?

Thank you very much!


Solution

  • A BigInteger can hold a number as large as how much memory your application can allocate. Thus the more memory your application is able to allocate, the larger number the structure can hold.