Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Format strings: how to format Scientific, but with only one digit for the exponent?

I'm using MS with VC#.  I have a NumericEdit that I'm using as a textbox.  I want to display numbers in a very specific format:

 

0.0000123 as: 1.2E-5

 

If I use "Engineering Notation" formatting EE1, I get 12.3E-6.  If I use "Scientific Notation" formating E1, I get 1.2E-005.

 

Is there any way to combine these?  I don't want to snap to base 3 exponents, and I only want to display the minimum number of digits in the exponent.

 

For example, some numbers I want to see are 0.0E+0, 9.9E-15, etc.

 

Ideas?

 

Will

0 Kudos
Message 1 of 4
(4,151 Views)

Hi Will,

 

Unfortunately I do not think you are going to achieve the exact format you are looking for without doing some customization.  As you have found the Engineering Notation will only give us exponents that are a multiple of three, yielding anywhere from 1-3 values in front of the decimal point and with Scientific Notation, you will have the three digits in the exponent.  There is no innate format to match your exact specifications.  

Cheers,
Kelly R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(4,132 Views)

When I use the formatting %.1e 

 

I get numbers that look like 3.3E+1 not 3.3E+001

 

How do I get the formatting to give me the 3 digits in the exponent??

 

Thanks.

0 Kudos
Message 3 of 4
(3,652 Views)

Where are you trying to enter this format string? It does not look like a numeric formatmode string. Are you using a Numeric Edit control?

National Instruments
0 Kudos
Message 4 of 4
(3,629 Views)