LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to number replaces decimal point to comma

I can't seem to get LabVIEW to keep the decimal point, it converts it to a comma.

I'm using 'Fract/Exp String To Number' with FALSE as using the system decimal point (LabVIEW documentation explicitly says that will produce a dot as decimal point). Note: my system is in fact using comma, but changing this has no effect. If I change the bool to TRUE it simply cuts off all decimals and returns an integer. Tried with both system decimal points.

 

See attached image for the simplest example you ever witnessed. Expected output is 1.1337, true output is 1,337

DecimalPointProblem.png

0 Kudos
Message 1 of 6
(1,788 Views)

Hi Xisten,

 


@XistenZ wrote:

Expected output is 1.1337, true output is 1,337

DecimalPointProblem.png


Your expectation might be wrong... 😄

 

The numeric indicator will use the system numeric (regional) settings as long as you don't switch off that behaviour in the LabVIEW options. (Did you?) What is the numeric format of your computer/user account?

(Did you restart LabVIEW wen changing the regional settings of your user account?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,780 Views)

The behaviour is expected, the True/False boolean tells the function whether to look for dot or comma in the input string and not in the output.

 

FYI, numeric data is stored as bits and it doesn't store anything about comma or dot, it is up to you how to display it when converted to a string. With this said, you have to update the Numeric Indicator's display format to use a dot instead of comma.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 3 of 6
(1,770 Views)

@GerdW wrote:

Hi Xisten,

 


@XistenZ wrote:

Expected output is 1.1337, true output is 1,337

DecimalPointProblem.png


Your expectation might be wrong... 😄

 

The numeric indicator will use the system numeric (regional) settings as long as you don't switch off that behaviour in the LabVIEW options. (Did you?) What is the numeric format of your computer/user account?

(Did you restart LabVIEW wen changing the regional settings of your user account?



I think my expectation is reasonable 😅

As I said there's a boolean in that function to tell LabVIEW not to use the systems settings to force it to simply use a dot. 

 

Changing the settings in either or both system and LabVIEW changes nothing in the behaviour. LabVIEW is a rebel that does not care as it seems.

0 Kudos
Message 4 of 6
(1,768 Views)

@santo_13 wrote:

The behaviour is expected, the True/False boolean tells the function whether to look for dot or comma in the input string and not in the output.

 

FYI, numeric data is stored as bits and it doesn't store anything about comma or dot, it is up to you how to display it when converted to a string. With this said, you have to update the Numeric Indicator's display format to use a dot instead of comma.


 

That explains it then, I assumed it was to convert the output. It also explains why it removes the decimals if I have it set incorrectly. Thanks!

0 Kudos
Message 5 of 6
(1,766 Views)

The data is in the wire and formatting only plays a role when the value is presented to the user, e.g. via an indicator. It is up to the indicator how to do that.

 

While you probably want to decide globally how decimal delimiters are displayed, you could change the formatting of any single numeric (control or indicator) to use the nondefault delimiter.

 

In my case, the delimiter is a decimal point, but if I also want an indicator with a comma, I can use the advance formatting of the numeric indicator to force a comma as follows:

 

%,; force comma for the rest of the format string

%.; force period for the rest of the format string

%; force the default delimiter.

 

(look for the section about "Localization Codes" here)

 

altenbach_0-1648576598725.png

 

0 Kudos
Message 6 of 6
(1,726 Views)