Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:35

0001 #include<limits>
0002 #include<iostream>
0003 #include<vector>
0004 #include<fstream>
0005 
0006 using namespace std;
0007 
0008 void print(double d)
0009 {
0010   cout.precision(26);
0011   cout.setf(ios_base::scientific,ios_base::floatfield);
0012   cout << d << endl;
0013 }
0014 
0015 int main()
0016 {
0017   numeric_limits<double> nl;
0018   cout << "radix   = " << nl.radix << endl
0019        << "digits  = " << nl.digits << endl
0020        << "digits10= " << nl.digits10 << endl
0021     ; 
0022 
0023   double d1(1), d10(10), dpi(3.141592);
0024   print(d1);
0025   print(d10);
0026   print(dpi);
0027   size_t sz(100000);
0028   vector<double> v(sz);
0029   vector<double>::iterator it(v.begin()), ed(v.end());
0030   size_t count(0);
0031   ofstream file("vector.txt");
0032   for(;it!=ed;++it) {
0033     *it = count++;
0034     double d(count);
0035     file.write((char *)(&d),sizeof(double));
0036   }
0037   
0038   
0039   
0040   cout << count << " non-zero entries." << endl; 
0041   return 0;
0042 }