LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Combining multiple ASCII to Number

Solved!
Go to solution

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!

0 Kudos
Message 1 of 4
(449 Views)
Solution
Accepted by TheMostLostStudent

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 4
(425 Views)

@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).

 

altenbach_0-1712503535106.png

 

 

 

0 Kudos
Message 3 of 4
(401 Views)

Thank you!

0 Kudos
Message 4 of 4
(392 Views)