ccplusplus.com
Learn C, C++ Concepts
Saturday, February 4, 2012
setprecision in c++ example
/************************************************************************* * File : setprecision-function.cpp * Author : Saurabh Gupta * Desc : setprecision in c++ example * Source : http://www.ccplusplus.com/p/c_15.html * Created : 4:39 PM Saturday, February 04, 2012 *************************************************************************/ #include
#include
// for setprecision() using namespace std; int main() { cout << setprecision(16); // show 16 digits float fValue = 3.33333333333333333333333333333333333333f; cout << fValue << endl; double dValue = 3.3333333333333333333333333333333333333; cout << dValue << endl; return 0; } /* * OUTPUT * [sgupta@rhel6x86 setprecision-function]$ c++ setprecision-function.cpp -o setprecision-function [sgupta@rhel6x86 setprecision-function]$ ./setprecision-function 3.333333253860474 3.333333333333334 [sgupta@rhel6x86 setprecision-function]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment