LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert numeric into string, but whitout the non significatives zeros in the decimal part ?

With the "number to fractional string", we can't automaticaly adjust the precision depending of the non significative zeros we can find at the end of the decimal part. For example, I want a precision of 3 decimals. So if my number is "3.1234", I want a string like "3.123", but if the number is "2.1" I want a string like "2.1" and not "2.100".
Does someone have the solution ?
0 Kudos
Message 1 of 7
(3,014 Views)
What version of LabVIEW are you using? With 7, you just use the format into string function and use %#.3f as the format string. The # symbol says to remove trailing zeroes.
0 Kudos
Message 2 of 7
(3,014 Views)
I use LabView 6.1
0 Kudos
Message 3 of 7
(3,014 Views)
After your conversion to a string, try a match pattern function with 0+$ as the expression and use the before sustring output.
0 Kudos
Message 4 of 7
(3,014 Views)
It works, except the "dot" if the number is "4.000", it writes "4." instead of "4".
0 Kudos
Message 5 of 7
(3,014 Views)
Then do another match pattern to remove the ".".
0 Kudos
Message 6 of 7
(3,014 Views)
Ok, thanks, now it works perfectly !!!
0 Kudos
Message 7 of 7
(3,014 Views)