I want to convert double to scientific notation like this:
-0.00752382528 => -.752383E-1
can i do this with .ToString() or Regex?
I want to convert double to scientific notation like this:
-0.00752382528 => -.752383E-1
can i do this with .ToString() or Regex?
You can either use the standard format string for scientific notation:
(-0.00752382528).ToString("E5") // returns "-7.52383E-003"
or if you don't want the leading zeros in the exponent, use a custom string:
(-0.00752382528).ToString("0.00000E0") // returns "-7.52383E-3"
© 2022 - 2024 — McMap. All rights reserved.
-.752383E-1
is not proper scientific notation - even if it were, it does not match your original value. – Barque