How to Set the Significant Digits on a Double-Precision Wire?

Updated Oct 19, 2020

I have a double-precision number with a bunch of numbers after the decimal. How do I set the wire to contain a number with X digits after the decimal?

There are three possible ways to accomplish this. The first one is the best method to use, but the others will work as well.
    • Method 1:
      1. Wire the double-precision value into a Number to Fractional String VI. The bottom input to this VI is the precision, or number of digits after the decimal place. The output of this VI should be a string containing the number with the correct significant digits. 
      2. To convert this back into a double-precision number, simply use a Frac/Exp String to Number VI. The output will be the number with the correct precision. This method also works for arrays of double-precision numbers. See attached VI.
    • Method 2:
      1. Wire the double-precision value to a numeric indicator.
      2. Right-click on the indicator and go to either Properties or Format Precision, depending on the data type (array or single number).
      3. Under Format and Precision, make sure the Precision Type is set to Significant Digits and then change the Digits numeric to the desired number.
      4. Click OK to save this configuration. Now you can create a local variable off of the indicator and use the value out from it.
    • Method 3:
      1. Multiply the double-precision number by a multiple of 10 to move the decimal place.
      2. Use the Round to Nearest VI to round the number off to an integer.
      3. Then divide by the same multiple of 10 to move the decimal point back.
    To download VIs that demonstrate how to set a double-precision value to three significant digits for each method, refer to the LabVIEW: Set the Significant Digits of a Double-Precision Wire Community example.