math - C# Rounding a negative exponential double value -


I tried to do everything, but decimal decimal value is 6 decimal with a very long decimal value (exponential)

  string str = "-1.7976931348623157E + 308"; Double d = double. Purse (str); D = Math.Round (D, 6, Midpoint Rounding. AeFomazero); String str 2 = D. ToString ();  

I want to result in -1.7 9 76 9, as simple as that!

Note that, according to the suggestion of small bubbibable, 1.xxE + 308 Going on 1.xx . But assuming that you did not mean it, and you are just trying to structate your output:

  string str2 = d.ToString ("E6");  

Where number is the number of numbers E6 that you want to display next to the e-sign.

For the above example, str2 will be the value of "- 1.797693E + 308" .

If you really need your value (and I'm not really sure why you will do this - why throw away the exact? It does not come out of your way) Code> Round should be placed as it stands above.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -