03-15-2013 05:37 AM
I got a small problem.
To convert a string to number, I use the function "scan value" with "%.3f" for the" format string" connector . I wish to get number with 3 digits. But it dosen't work with the setting of "%.3f".
Thanks.
Solved! Go to Solution.
03-15-2013 05:50 AM
Those kind of specifiers are used to format numbers into strings, not the opposite. If you need to cut digits in excess, you have to do it by code, reading the input as a string.
03-15-2013 06:08 AM
To expand on that, there's no such thing as a floating point number with three digits. The number will almost always be close to the fraction you want, but not exact. The format code controls how the number is converted for a string, usually for display. Here are some options:
03-15-2013 06:24 AM
But if I put "%5.f" instead of "%.3f" with the" format string" connector, it works,i.e. cuts the number into 5 numbers including period ("256.34567"->256.3).
03-15-2013 06:32 AM - edited 03-15-2013 06:33 AM
Please check the Format Specifier Syntax in the LV help. There is a table describing the purpose of each specifier. When you read in the description "when you use a formatting function", the specifier applies to number->string, when you read "when you use a scanning function", the specifier applies to string->number. The Width syntax element applies to both situations, the .Precision syntax element does not.
03-15-2013 06:38 AM
Thanks.