04-07-2024 06:58 AM
Hello!
I'm trying to combine multiple ASCII characters to form a large number. I've started off with a simple setup to get to grips with it but I'm a tad lost.
The idea is you have a 4 ASCII input between A and J. Then they're converted to numbers 0 to 9, and then converted to a combined number. Eg. ABCD ->> 0123. I've converted to individual numbers, and tried combining them using various methods now, but nothings quite working.
Any help would be much appreciated!
Solved! Go to Solution.
04-07-2024 08:19 AM - edited 04-07-2024 08:19 AM
You have the right idea with String To Byte Array. But you can subtract directly with the array. You should also subtract 17, which is the difference between 'A' and '0'. After the subtraction, use Byte Array To String and then Decimal String To Number.
04-07-2024 10:27 AM - edited 04-07-2024 10:29 AM
@TheMostLostStudent wrote:
I'm trying to combine multiple ASCII characters to form a large number.
(sorry, cannot see your VI, on LabVIEW 2020 here on my current computer)
I guess the problem is with your definition of "large number". If it is larger than 18446744073709551615 (max for U64), you cannot represent it using a numeric datatype and you need to decide how the output is shown (array of single digit numbers, just a string with characters 0..9?)
You also probably need to validate the input to generate an error if any of the values is not in the range A..J.
In any case, the following will work for any string up to 2147483647 characters in length, assuming that the input is clean. (given sufficient memory).
04-07-2024 10:41 AM
Thank you!