Question Custom formatting of decimal numbers

astevens

Member
Joined
Jun 30, 2010
Messages
5
Programming Experience
1-3
I'm having a bit of an issue getting the number formatting of VB .NET 3.5 to work just right for me.

I have to convert numbers to scientific notation, with 2 digits for the exponent and 6 digits after the decimal. I've been able to get this for numbers that have enough digits, but for other numbers, it truncates the number to use as few digits as possible.

For example, I would like 0 to be converted to 0.000000e00, or 123.4 to be 1.234000e02.

My current formatting string is
VB.NET:
val.ToString("#.######E-##")
 
Back
Top