LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number to string with decimal separator

Solved!
Go to solution

Hello Community,

 

I would like to convert numbers to string with decimal separators. So if the number is 52351 then the string I need is 52,351

another example 18653284.9653235 should become 18,653,284.9653235

 

What would be the easiest way to do this?

 

thanks!

0 Kudos
Message 1 of 8
(3,831 Views)
Solution
Accepted by topic author 1984

Read through this thread: https://forums.ni.com/t5/LabVIEW/comma-separator-for-large-numbers-how-to/m-p/2123090/highlight/true...

 

Not the first person to wish for this idea.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 2 of 8
(3,824 Views)

Be sure to vote for this idea.  Visual Aides - Numeric Separators

0 Kudos
Message 3 of 8
(3,804 Views)

Your subject line is a bit misleading.

 

You are apparently not talking about a "decimal seperator", but a "thousands separator". (See e.g. this section). 

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

Alright, so I have a CLA, a knight of NI and a LabVIEW champion answering my question. I feel kinda spoiled here 🙂

Yeap, the subject line can be a bit misleading, but apparently I am not a native speaker.

 

Thanks for the link though!

0 Kudos
Message 5 of 8
(3,755 Views)

Actually, all 3 of us are champions.  I just don't put it in the signature, and Thoric's is cutoff.

 

Once I got reading your message, I realized what you were looking for.  Having a numeric indicator with commas separating thousands is something I've wanted for a while.  Actually, controls also,  A control would probably need some extra code behind the scenes to properly parse out what a user might type as to whether it had commas or not, or if they were misplaced, to fix them.

0 Kudos
Message 6 of 8
(3,739 Views)

Even better 🙂

 

But I am not interested in the numeric control, I am interested in converting a number into a string with thousands separators. While I could do it with the classic method of analyizing the string and put commas to the right place I though there could be an easier way (eg a format specifier). It seems we dont have such thing though. The forum posted by Thoric has a code for integers, that will work for me.

 

Thanks.

0 Kudos
Message 7 of 8
(3,720 Views)

The problem with an automatic formating is that there is not a single character around the world that works everywhere. In fact several countries use the comma as decimal seperator and the apostrophe as thousend seperator, but that is by far not the only possible variation around the globe. While LabVIEW allows for decimal comma and decimal point formatting throughout the entire string functions, adding an option for thousend seperator too would be a major project that is hard to do without breaking old software.

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(3,698 Views)