LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decimal String to Number Conversion, cutting off needed zeros

Solved!
Go to solution

I am new to the forum, but have been using labview for a while. Finally found something that really stumped me, hope I can find someone who is smarter than me! It may be an obvious thing too, but here it goes. The vi attached is the root cause of the error. I have a serial number that I need to convert from a decimal string into a number, I later use the number for "math" so need it in number form. The system always receives a 6 character serial number (ie. 123456), but today the system received a serial with two zeros preceding the ladder digits (ie. 003456). This set off all the alarm bells down stream (4 digits sent), but tracing the error found it started at the "smarts" at the beginning for the program. I would like to know if there is a way to force the the Decimal Number to String to not shave the preceding zeros off of the 6 digit value.

 

File is in LabVIEW 2014

 

Any thoughts or comments, Thanks!

 

 

0 Kudos
Message 1 of 10
(4,312 Views)
Solution
Accepted by topic author CarbideETN

The problem is not the string functions.  It is the display format for your numeric indicator.  Change the properties on that.

 

Message 2 of 10
(4,295 Views)

You are correct,  that did fix the "Indicator" but the value if probed is only the four digits. I need to use the data later with the padded zeros. Thanks for the help!

0 Kudos
Message 3 of 10
(4,278 Views)

When you have a number, it is a number.  What it looks like probed or displayed doesn't change the number.   001234 is equal to 1234.  The only difference is the way they are displayed.  If you need a probe on a wire to show it with padded zeroes, then create a custom probe.

 

 

0 Kudos
Message 4 of 10
(4,263 Views)

Thanks the help, I do agree with you. I created a work around that fixed my problem. I appreciate your time!

0 Kudos
Message 5 of 10
(4,244 Views)

By any chance, are you trying to comapre these serial numbers as floating point numbers?  This will cause problems if you do calculations to reach the any of the serial numbers.  While integers are represented exactly in FP numbers, if you did any kind of calculations using or resulting in fractional numbers, you may have comparison issues.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 10
(4,208 Views)

Maybe you can describe or upload your workaround so others can benefit from your acquired wisdom.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 10
(4,204 Views)

Thanks for the interest billko, the png attached is my work around. The issue started during the input, so two values are captured: original serial string length & post decimal string to number conversion length. The difference is  then fed into a simple state machine that dictates the amount of zeros to be added or ignored. The state machine can handle, no change, 0,00,000,0000 zeros. It then concatenates the correct number of zeros as needed for each serial number. Works great!

0 Kudos
Message 8 of 10
(4,124 Views)

Technically that is not a state machine.  Those are just case structures.

 

Now you are working with strings again, when originally you were complaining that the numeric indicator and probes weren't showing leading zeroes.

 

All of that is just complicated Rube Goldberg Code

 

Just use Format into String.

 

 

0 Kudos
Message 9 of 10
(4,114 Views)

lol, I like that terminology. That is much simpler, I will have to use it. Thanks for your expertise, learned something new today!

0 Kudos
Message 10 of 10
(4,095 Views)