Showing results for 
Search instead for 
Did you mean: 

separate integer digits to array

Greetings all

Can someone tell me how do i separate integer in to separate digits in an array.

Eg: 4409

array elements: 44



Thanks and Regards


0 Kudos
Message 1 of 9

Aren't these four digits: 4 4 0 9 ?

0 Kudos
Message 2 of 9


it is but since those are integers 09 will be 9

Thanks and regards


0 Kudos
Message 3 of 9

So you don't' want to separate digits.  You want to separate PAIRS of digits?

0 Kudos
Message 4 of 9

This is how I would do it. If you change the 2 to a different number it would give how ever many digits.


Seperate Numbers.png

0 Kudos
Message 5 of 9

I would use Quotient and Remainder and divide by 100.

Message 6 of 9

You are still not giving us sufficient information.


  • Is the input a string with four character or a numeric?
  • If it is a numeric, what is the datatype?
  • Are negative inputs allowed, and if so, how should they be handled?
  • Is it always four digits or can it be variable length?
  • What should be the output datatype?

Typically it is much easier to solve a problem if you would attach a very simple VI that contains the actual data and desired output.


Here's a slightly more scalable version of the above that can deal with any number of digits supported and will output all decimal digit pairs of the positive input integer.



Message 7 of 9

All of the previous methods have been a simple way to accomplish this problem, so I decided to make a hard way to accomplish this problem. I also assumed that the task is to get each single digit, not pairs of digits; if you want pairs of digits, that is left as an exercise to the reader.



0 Kudos
Message 8 of 9

I like Bert's solution, but the latent Mathematician in me calls out for a Recursive solution (which, of course, is very simple to write in LabVIEW).  I made the input a U32, thereby getting rid of a possible ambiguity if you put in a negative integer.  I also assumed that the number 4409 (using our usual "digit-place representation" of numbers, has the digits "4", "4", "0", and "9".  Here is the (almost trivial) VI, showing the Recursive call -- this version puts the digits of 4409 in an Array starting with the Least Significant Digit (i.e. "9") -- reversing the order of building the Array will give the digits in the reverse order.  Enjoy!

U32 to DigitsU32 to Digits

 Bob Schor


Message 9 of 9