LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Significant Figures instead of Precision

Solved!
Go to solution

Hi all,

 

Was hoping someone could make a recommendation on my code.  I've got a cluster of numerics that I'm converting to strings so I can concatenate and spit out to a text file.  I put 2 probes in, 1 before and 1 after the conversion and can't figure how to get the formatting to follow through.

 

What you see on probe 4 is what I'd like to see it come out of the function or some other formatting function.  I could drop the precision down to 0 on the  "Number to fractional string" function and it would spit out what I want for that case.  However it won't always be a whole number at probe 4.  Some cases will be xyz.x - and if we put that to zero, then we're going to loose that decimal.  (almost all values will be decimal).

 

 Essentially, I just need to remove the trailing zeros as is set in the display format properties of each element in the numberic cluster.

LV7.1, LV8.5, LV2014/15/16
0 Kudos
Message 1 of 8
(4,586 Views)

Hi,

 

Take a look at the attachment.

 

Hope it helps,

Paulo

0 Kudos
Message 2 of 8
(4,573 Views)

I'll draw up an example, but I can tell you now, use the format into string VI. Read the context help on it and it should clear things up. Tip: you can double click it and set all the properties if you aren't familiar with setting string formating with things such as %0.4f etc. Using this function will allow you to get rid of that giant concatenation of strings, with a space constant wired in multiple different places.

 

Anyways, look into it and I'll try to draw up a short example.

0 Kudos
Message 3 of 8
(4,572 Views)

Replace the number to decimal string with a format to: It is located in the same spot on the palet

 

Example_VI_BD.png

Tim
GHSP
0 Kudos
Message 4 of 8
(4,562 Views)

Here, and you can set the display digits for the indicator by right clicking and choosing "display properties". The dialog shown will come up and you can select that way. You can then, after the for loop, use concatenate string to add carriage returns and whatever is in those case structures, before writing to a file.

 

Message Edited by for(imstuck) on 04-08-2010 12:11 PM
0 Kudos
Message 5 of 8
(4,560 Views)

@aeastet:

 

Tried swapping that out and looked good...till I used a more realistic value, lets say 111.1

 

That drops the decimal entirely.

 

Basically, I have a known number of character places to use up.  Each element has room for 4 digits when written to the text file.  The values should be passed like this:

 

Numeric --> String

1000     --> 1000

1001     --> 1001

1           --> 1.000

1.001    --> 1.001

12.12    --> 12.12

12.1234 -->12.12

 

etc.

LV7.1, LV8.5, LV2014/15/16
0 Kudos
Message 6 of 8
(4,535 Views)
Solution
Accepted by topic author DL84

@for(imstruck):

 

Looks like "%#.3f "

 

Will spit out the response I was trying to get.  Thanks for the stepping stone!

LV7.1, LV8.5, LV2014/15/16
0 Kudos
Message 7 of 8
(4,526 Views)
glad to help.
0 Kudos
Message 8 of 8
(4,505 Views)