-1

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!

5
  • "available in VB .NET are Decimal and UInt64", what type are you using instead? Commented May 4, 2017 at 10:32
  • Use the BigInteger structure. It is not a native VB data type and is a member of the System.Numerics namespace rather than System. Commented May 4, 2017 at 11:19
  • That's what I'm using, but I get OverflowExceptions nonetheless when using functions like Convert.ToInt64, or even making my own functions converting Binary to Decimal. There isn't any variable type I can use to contain my numbers... Commented May 4, 2017 at 11:19
  • by "car ECU" do you mean CAN-bus? Can you show a sample of the data from your data sheets? Commented May 4, 2017 at 11:20
  • David: kind of. My ECU has an embedded software, and I'm basically making a software auto calculating some parameters that I will afterwards send it through CAN. The sent data is just random, lengthy hex numbers like 76576AB77AAA86733H54567890BFFF... But have critical signification. Commented May 4, 2017 at 12:53

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Oh wow! Thank you so much! But unfortunately I can't seem to import the class to my project. Is it in truly in System.Numerics? Because Visual Studio can't seem to find it (I have .NET 4.6). Thanks again!
Answering to myself: you must add it as a reference through Visual Studio in the menu Project > Add Reference > Assemblys > Framework > System.Numerics. Thanks again!
@user7831458 : You ought to do the same for any old, answered questions as well. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.