ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

automatic string formatting algorithm

What is LabVIEW’s algorithm for automatically formatting numbers?

I’m porting some LabVIEW code to C#, and I want to exactly duplicate the functionality of LabVIEW’s “Format Into String” function with “%#_6g” for its “format string” input.

0 Kudos
Message 1 of 5
(3,779 Views)
I don't understand your question. What do you mean by the algorithm for automatically formatting numbers? The Format Into String function outputs a string based on the format that you specify, so there's nothing "automatic" about it. It's no different than String.Format().
0 Kudos
Message 2 of 5
(3,767 Views)

That letter "g" in the string "%#_6g" means LabVIEW is automatically formatting the number between floating point and scientific notation.

 

To see this, drop a numeric control on the front panel, pop up on it to select its "Format & Precision..." menu item, then switch between "Automatic formatting" and any other format in that list, like "Scientific". When you switch to a new item in that list, switch to "Advanced Editing Mode" to see that the Format string has a "g" in it when it's on "Automatic formatting". 

0 Kudos
Message 3 of 5
(3,750 Views)

The %g format system works like this:

If the exponent of the number is between E+5 and E-4 (inclusive), it will format it as a normal floating point (%f) but if the number is outside this range it will have scientific notation format (%e).

Message Edited by Karissa on 08-14-2008 10:29 PM
_______________________________________
Systems Test Engineer
Certified LabVIEW Architect (CLA)
0 Kudos
Message 4 of 5
(3,738 Views)
That seems simple, thanks.
0 Kudos
Message 5 of 5
(3,722 Views)