LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number to array of digits

I have a number (value between 0 and 10,000,000), and I need to convert it to a 8-element array of digits, with left hand zeros as placeholders.  Any suggestions?
Thanks
Matt
0 Kudos
Message 1 of 7
(3,249 Views)

You can convert the number to a string, and then parse the string.  

Another option would be to do things with calculus...   Basicly, do a quotient & remainder with mutliples of 10.  



Message Edited by Anthony de Vries on 04-22-2008 05:54 PM
0 Kudos
Message 2 of 7
(3,245 Views)
Below is another way to do it.  There is no checking to make sure the number is eight digits or less, so you may want to write that in, as well as any other error checking you think is necessary.

Cheers!






Message Edited by jmcbee on 04-22-2008 10:04 AM
0 Kudos
Message 3 of 7
(3,237 Views)
Can also do without loops



Message Edited by smercurio_fc on 04-22-2008 11:51 AM
0 Kudos
Message 4 of 7
(3,219 Views)


smercurio_fc wrote:
Can also do without loops

Exactly! 🙂
 
I would check the range of the input with the desired boundaries, else there is a chance that the output array is more than 8 digits.. Also, the 48 diagram constant should be U8 to avoid the measles. :o:D
 

 


You might want to adjust the upper limit to exactly what you need. Also (include or exclude it as needed)

Message Edited by altenbach on 04-22-2008 10:21 AM
0 Kudos
Message 5 of 7
(3,210 Views)

@altenbach wrote:

Also, the 48 diagram constant should be U8 to avoid the measles. :o:D


Hah! Quite right. Goes to show you what happens when you slap something together quickly! Although I wonder if my aging eyes might have something to do with it. Smiley Very Happy
Message 6 of 7
(3,195 Views)
Thanks to all for the help.  I am back in business.
Matt

0 Kudos
Message 7 of 7
(3,176 Views)