Functions _ gcvt and _ gcvt_s can convert floating point numbers to strings. I have a limit in http://blog.csdn.net/master_feng2009/article/details/9446355.
However, when the floating point number is an infinite decimal number, the conversion to a string may automatically become a scientific notation, and in some cases, it should not be converted to a scientific or technical method, such as executing an SQL statement, when floating point data is inserted, an error occurs if it is a scientific counting rule.
So how can we avoid automatic conversion to scientific notation? The following method can be used:
Double dprecision;
Dprecision = 0.06666666666666;
_ Gcvt_s (carray, dprecision, 20); // The output result is 6.66666666660004e-002.
Ostrstreamos;
Istreamin (OS. rdbuf ());
OS <Endl;
OS <dprecision;
OS <ends;
In> carray; // result, 0.0666667, not scientific notation
Note: The header file must be included.# Include
<Strstream>.