c# - Why does my floating point value have an `E` character when I convert it to a string? -


txtdebuglog.invoke(new methodinvoker(delegate() {     fps.frame();     ggg = fps.getfps();     txtdebuglog.text = string.format("{0}\r\n{1}", ggg, txtdebuglog.text); }) 

txtdebuglog textbox.

using breakpoint see on ggg in example it's value is:

0.00000102593151 

then click on continue , see in textbox:

1.025932e-06 

your floating point value ggg has small value. when convert string, happens in call

string.format("{0}\r\n{1}", ggg, txtdebuglog.text);  

it converted string uses exponential format represent value. can read exponential format is, referred scientific notation, here.

if want use different format, have specify yourself. many standard formats available, can explicitly specify when doing conversion. conversion of double string using specific format can done calling double.tostring(format) method.

several standard formats available , listed there, including output them.

the default format used if not specify one, general format specifier ("g"), which:

converts number most compact of either fixed-point or scientific notation, depending on type of number , whether precision specifier present. precision specifier defines maximum number of significant digits can appear in result string.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -