# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Combining multiple ASCII to Number

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!

Message 1 of 4
(245 Views)
Solution
Accepted by topic author TheMostLostStudent

## Re: Combining multiple ASCII to Number

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.

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
Message 2 of 4
(221 Views)

## Re: Combining multiple ASCII to Number

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

Message 3 of 4
(197 Views)

Thank you!

Message 4 of 4
(188 Views)