LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan/Format from/into String Question

Solved!
Go to solution

Refer to my attachment

 

For format into string, the precision comes first and the width (includes the decimal point, right?) comes second.  

 

For scan from string, it seems to be opposite, width comes first and precision second.  

 

Is what I am saying correct?  Why is it like this?  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 3
(2,307 Views)
Solution
Accepted by topic author jyang72211

If you right-click on the scan from string or format to string and choose Edit Scan String or Edit Format String (or read the help), you will see there is a difference.

 

In Scan From String, digits of precision is not used.  The width number has different meanings between the functions as well.  In Format to String, it is the mimimum field width.  In Scan From String, is is the width.  So, in your Scan from String, %5.4f is equivalent ot %5f, which will only take the first 5 characters.  In you Format to String, %5.4f means the minimum field width is 5 and you want 4 digits.  You can see you actually got 7 characters out, because it needed more than 5.

Message 2 of 3
(2,288 Views)

oh, that's clear.  Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 3 of 3
(2,267 Views)