LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question regarding Format Specifier Syntax

Solved!
Go to solution

Dear community,

 

I am trying to write data out to an Excel file, this is functioning properly. My problem is that I am not able to get the correct number of decimal points in my data. I would like to have three decimal points after a comma (not a period) and am currently using "%,;%3d" as a format specifier syntax but it seems to round the data to numbers with no decimal points. Below I have attached two screenshots, one of the VI and one of said output file. 

 

Any suggestions would be great!

 

Thanks in advance,

 

Screenshot.pngScreenshot Excel.png

0 Kudos
Message 1 of 4
(4,476 Views)
Solution
Accepted by topic author MDijkstra
Use .3f. The .3 is for the number of decimal places and the f is for a floating point number.
0 Kudos
Message 2 of 4
(4,452 Views)

%d formats numbers as decimal. Use %f instead...

 

Type Argument(s) Format String Resulting String Comments
Automatic Formatting (%g) 12.00 %#g 12 If you specify #, LabVIEW removes trailing zeros. If you specify g, LabVIEW chooses scientific notation or floating-point notation based on the number to format.
12000000 %#g 1.2E+6
Decimal (%d) 12.67 score= %d%% score= 13% When you specify %d, LabVIEW rounds the argument. Use %% to format a single %.
Floating-Point (%f) 12.67 Temp: %5.1f Temp: 12.7 The 5 in the Format String section specifies a width of 5, and the 1 specifies the number of digits to the right of the decimal, or precision.
12.67 N %5.3f 12.670 N Units are valid only if you use the Format Into Stringor Scan From String functions. These are examples of physical quantity input. The second example shows how you can convert from one unit to another. The question mark indicates when the unit in the format specifier is in conflict with the input unit.
12.67 N %5.3{mN}f 12670.000 mN
12.67 N %5.3{kg}f 12.670 ?kg

Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 3 of 4
(4,449 Views)

Thanks a bunch! Seems to be working properly 🙂

0 Kudos
Message 4 of 4
(4,408 Views)