07-03-2014 06:23 AM
HI,
I found a measurement studio formatter for SI notation.
For details, see the NI document.
Here, I want to know how to remove any trailing zeros. I could not find any information about this.
For example,
code : string result = string.Format(EngineeringFormatInfo.Default, {0:s5}, double value)
if value = 1.2345678E-3, result is 1.23457E-3. It is ok.
if value = 1.2E-3, result is 1.20000E-3. But I want to get "1.23m".
In labview, I usually use "%#.5p" format string.
07-03-2014 08:52 AM
@diluculo wrote:
HI,
I found a measurement studio formatter for SI notation.
For details, see the NI document.
Here, I want to know how to remove any trailing zeros. I could not find any information about this.
For example,
code : string result = string.Format(EngineeringFormatInfo.Default, {0:s5}, double value)
if value = 1.2345678E-3, result is 1.23457E-3. It is ok.
if value = 1.2E-3, result is 1.20000E-3. But I want to get "1.23m".
In labview, I usually use "%#.5p" format string.
I don't understand how you are getting 1.23457E-3 ? And claiming that is okay.
If you are using the format string that you claim you are using, then you should be getting 1.23457m.
It sounds like you are using string result = string.Format(EngineeringFormatInfo.Default, {0:E5}, value)
07-03-2014 10:05 AM
07-03-2014 10:15 AM
07-03-2014 01:47 PM
@diluculo wrote:
code : string result = string.Format(EngineeringFormatInfo.Default, {0:s5}, value)
value = 1.2345678E-3 -> result = "1.23457m"
value = 1.23E-3 -> result = "1.23000m". But I want to get "1.23m" without trailing zeros.
Based on the documentation page you linked, the answer is no.
07-03-2014 07:26 PM
So, unfortunately, there is no native way to format numbers in metric units even in the Measurement Studio.
Thanks.
07-07-2014 09:53 AM
I believe the formatter is working as expected, treating the value as containing five significant digits after the decimal (including trailing zeros). Using scientific notation, the value 1.23000 indicates a more precise value than 1.23 with the trailing significant digits removed.
Unfortunately, I do not know of any existing format mode that supports a "maximum digit count" (they either show all digits, or an "absolute digit count").