Convert decimal value to exponential value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajprakash
    New Member
    • Feb 2007
    • 70

    Convert decimal value to exponential value

    Hi, I have a decimal number. I need to convert this decimal value to exponential value. I have a vb.net code to convert from decimal to exponential value is Format(100000, #.0#E-##) . When I run this code in vb.net it returns 1.0E5

    I need the same expression for the c#.
    I am using the following code String.Format(" {0:E}", 100000) and its returns 1.000000E+005, but I need 1.0E5. The same for the another value String.Format(" {0:E}", 0.000597), I need 5.97E-4 but it is returning 5.970000E-004. Does anyone let me know the right expression
  • pankajprakash
    New Member
    • Feb 2007
    • 70

    #2
    Got the solution

    string.Format(" {0:#.0#E-00}", 1000000);

    Comment

    Working...