Convert double to scientific notation with specific number after decimal points

╄→гoц情女王★ 提交于 2019-12-07 12:23:35

问题


I want to convert double to scientific notation like this:

-0.00752382528 => -.752383E-1

can i do this with .ToString() or Regex?


回答1:


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"


来源:https://stackoverflow.com/questions/25851179/convert-double-to-scientific-notation-with-specific-number-after-decimal-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!