From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LV 2017 ignores format string for double

Solved!
Go to solution

Hello!

 

I have a little "homework" I need to hand in tomorrow, and one of the questions is:

Give a format string which you can read in a data with 6 decimal points. The decimal delimiter is point. I live in Hungary, therefore the system default is ",".

 

My current format string according to the official help is: %.;%.6f

But the .6f part seems to be ignored by LV. It reads every decimal. The digit before the dot (width) does have effect on the output.

 

What can be wrong?

 

See attachments for example. (there is another test.txt with commas instead of dots, but that does not matter)

 

Thanks in advance for the reply.

Download All
0 Kudos
Message 1 of 3
(2,734 Views)
Solution
Accepted by topic author quailstorm

It is documented that scanning a string uses a simplfied format where only the conversion code is used.

 

%[Width]Conversion Code

 

If you want to see fewer digits, adjust the format of the indicators.

 

Many exact decimal values cannot be represented exactly in binary (e.g. 0.1), so the value of any numeric will be the closest binary value, which might have other nonzero decimal digits on the far right once you display many.

Message 2 of 3
(2,687 Views)

Thanks, I totally missed that part. I see now, I can only use this C style format string to convert from numeric or numeric array to string. But since LV has its own logic there is no need to round or cut inputs I guess.

 

About floating point numbers, I know that is the reason of the weird endings, but the last number in my txt had more than 6 decimals. That was the test number (0.11111122222225).

0 Kudos
Message 3 of 3
(2,675 Views)