此內容不適用於您所偏好的語言。

此內容已顯示為其他適用語言。 您的瀏覽器可能含有可協助翻譯的套件。

Convert Floating Point Number to String Using a Comma or Period as Decimal Point

Updated Jul 6, 2022

Environment

Software

  • LabVIEW

I am writing an application that will be used by people with in many countries and need consistent behavior when converting floating point numbers to strings. For example, on 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?

Option 1
This can be accomplished using the Format Into String function in LabVIEW. 
  1. Double-click the function to see the Edit Format String dialog box.
  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
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 editing the dialog box and results in a fractional number.