Convert Floating Point Number to String in LabVIEW Using a Comma or Period As Decimal Point

Updated Oct 25, 2023

Environment

Software

  • LabVIEW

I am writing an application that will be used by people within many countries and needs consistent behaviour when converting floating point numbers to strings.
For example, on a system with the language set to German, convert to string uses a comma instead of a period for the decimal point.
I have a number that I want to convert to a string, but I want the string to always use a comma or always use a period as the decimal point, regardless of the language of the user's OS. How can I do this?

This can be accomplished by using the Format Into String function. You can either use the interactive 'Edit Format String' configuration pop-up or by directly specify the formatting options in a string constant. 
 

Option 1: Edit Format String Configuration Pop-Up

This can be accomplished using the Format Into String function in LabVIEW. 
  1. Double-click the function to see the Edit Format String configuration pop-up.
  2. Choose Specify Decimal Point Character from the Selected Operation menu ring.
  3. Choose your decimal point (comma or period), then click on Add New Operation.
  4. Choose how you want to format the number from the Selected Operation menu ring.
  5. Click OK when you are done.

 

Option 2: String Constant

You can also create a string constant on the Format String terminal and input %,;%f .to default to a comma or %.;%f to default to a period. This will accomplish the same functionality as using the configuration pop-up and results in a fractional number.


Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.