Discussion:
automatic string formatting algorithm
(too old to reply)
bmihura
2008-08-14 20:10:06 UTC
Permalink
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.
smercurio_fc
2008-08-14 20:40:06 UTC
Permalink
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().
bmihura
2008-08-15 00:40:18 UTC
Permalink
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". 
Karissa
2008-08-15 03:40:07 UTC
Permalink
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
bmihura
2008-08-15 12:10:05 UTC
Permalink
That seems simple, thanks.

Continue reading on narkive:
Loading...