11-19-2019 11:44 PM
Greetings all
Can someone tell me how do i separate integer in to separate digits in an array.
Eg: 4409
array elements: 44
9
Thanks and Regards
Baig
11-20-2019 01:32 AM
Aren't these four digits: 4 4 0 9 ?
11-20-2019 02:17 AM
Hi
it is but since those are integers 09 will be 9
Thanks and regards
Baig
11-20-2019 07:30 AM
So you don't' want to separate digits. You want to separate PAIRS of digits?
11-20-2019 07:52 AM
This is how I would do it. If you change the 2 to a different number it would give how ever many digits.
11-20-2019 10:14 AM - edited 11-20-2019 10:15 AM
I would use Quotient and Remainder and divide by 100.
11-20-2019 11:05 AM
You are still not giving us sufficient information.
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.
11-20-2019 01:16 PM
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.
11-20-2019 03:40 PM
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!
Bob Schor