当前位置: 首页>>代码示例>>C++>>正文


C++ ostream::precision方法代码示例

本文整理汇总了C++中ostream::precision方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::precision方法的具体用法?C++ ostream::precision怎么用?C++ ostream::precision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ostream的用法示例。


在下文中一共展示了ostream::precision方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exc

void OrbElemRinex :: dumpTerse(ostream& s) const
throw(InvalidRequest )
{

    // Check if the subframes have been loaded before attempting
    // to dump them.
    if (!dataLoaded())
    {
        InvalidRequest exc("No data in the object");
        GPSTK_THROW(exc);
    }

    ios::fmtflags oldFlags = s.flags();

    s.setf(ios::fixed, ios::floatfield);
    s.setf(ios::right, ios::adjustfield);
    s.setf(ios::uppercase);
    s.precision(0);
    s.fill(' ');

    SVNumXRef svNumXRef;
    int NAVSTARNum = 0;
    try
    {
        NAVSTARNum = svNumXRef.getNAVSTAR(satID.id, ctToe );


        s << setw(2) << " " << NAVSTARNum << "  ";
    }
    catch(NoNAVSTARNumberFound)
    {
        s << "  XX  ";
    }

    s << setw(2) << satID.id << " ! ";

    string tform = "%3j %02H:%02M:%02S";

    s << printTime(beginValid, tform) << " ! ";
    s << printTime(ctToe, tform) << " ! ";
    s << printTime(endValid, tform) << " !  ";

    s << setw(4) << setprecision(1) << getAccuracy() << "  ! ";
    s << "0x" << setfill('0') << hex << setw(3) << IODC << " ! ";
    s << "0x" << setfill('0')  << setw(2) << health;
    s << setfill(' ') << dec;
    s << "   " << setw(2) << health << " ! ";

    s << endl;
    s.flags(oldFlags);

} // end of dumpTerse()
开发者ID:xiangyan66,项目名称:GPSTk,代码行数:52,代码来源:OrbElemRinex.cpp

示例2: print_value

void  field_value_t::print_value(ostream & os)
{
    assert (_pfield_desc);

    if (_null_flag) {
	os << "(null)";
	return;
    }

    switch (_pfield_desc->type()) {
    case SQL_BIT:
	os <<_value._bit;
	break;
    case SQL_SMALLINT:
	os <<_value._smallint;
	break;
    case SQL_CHAR:
	os <<_value._char;
	break;
    case SQL_INT:
	os << _value._int;
	break;
    case SQL_FLOAT:
	os << fixed;
	os.precision(2);
	os << _value._float;
	break;
    case SQL_LONG:
	os << _value._long;
	break;
    case SQL_TIME:
        char mstr[32];
        _value._time->string(mstr,32);
	os << mstr;
	break;
    case SQL_VARCHAR:
    case SQL_FIXCHAR:
	//os << "\"";
	for (uint i=0; i<_real_size; i++) {
	    if (_value._string[i]) os << _value._string[i];
	}
	//os << "\"";
	break;
    case SQL_NUMERIC:
    case SQL_SNUMERIC: {
	for (uint i=0; i<_real_size; i++) {
	    if (_value._string[i]) os << _value._string[i];
	}
	break;
    }
    }
}
开发者ID:glycerine,项目名称:shore-mt,代码行数:52,代码来源:shore_field.cpp

示例3: dump

void BrcClockCorrection::dump(ostream& s) const
{
    const ios::fmtflags oldFlags = s.flags();
    s.setf(ios::fixed, ios::floatfield);
    s.setf(ios::right, ios::adjustfield);
    s.setf(ios::uppercase);
    s.precision(0);
    s.fill(' ');

    s << "****************************************************************"
      << "************" << endl
      << "Broadcast Ephemeris (Engineering Units)" << endl
      << endl
      << "PRN : " << setw(2) << PRNID << endl
      << endl;

    s << "              Week(10bt)     SOW     DOW   UTD     SOD"
      << "  MM/DD/YYYY   HH:MM:SS\n";
    s << "Clock Epoch:  ";

    timeDisplay(s, getEpochTime());
    s << endl;

    s.setf(ios::scientific, ios::floatfield);
    s.precision(11);

    s << endl
      << "           CLOCK"
      << endl
      << endl
      << "Bias T0:     " << setw(18) << af0 << " sec" << endl
      << "Drift:       " << setw(18) << af1 << " sec/sec" << endl
      << "Drift rate:  " << setw(18) << af2 << " sec/(sec**2)" << endl;

    s << "****************************************************************"
      << "************" << endl;

    s.flags(oldFlags);
}
开发者ID:rumkex,项目名称:GPSTk,代码行数:39,代码来源:BrcClockCorrection.cpp

示例4: WriteArea

void Scalene::WriteArea(ostream &outs) const
{
    float s = 0.5 * (side1 + side2 + side3);
    float a = sqrt(s * (s - side1) * (s - side2) * (s - side3));

    outs.setf(ios::showpoint);
    outs.setf(ios::fixed);
    outs.precision(2);

    outs << "The area of a scalene with sides of " <<
            side1 << ", " << side2 << ", and " << side3 <<
            " is " << a;
}
开发者ID:KGBOperative,项目名称:CS360_OOP,代码行数:13,代码来源:Scalene.cpp

示例5: freqest

int freqest(const FrequencyData& fd, const peakdata::Scan& scanIn, peakdata::Scan& scanOut,
            const Configuration& config, const string& outputDirectory, ostream& report)
{
    // instantiate FrequencyEstimator

    auto_ptr<FrequencyEstimator> fe;

    if (config.freqest_type == config.freqest_type_physical)
    {
        FrequencyEstimatorPhysicalModel::Config fepmConfig;
        fepmConfig.windowRadius = config.freqest_physical_window_radius;
        fepmConfig.iterationCount = config.freqest_physical_iteration_count;
        fepmConfig.outputDirectory = outputDirectory;
        fe = FrequencyEstimatorPhysicalModel::create(fepmConfig);
    }
    else if (config.freqest_type == config.freqest_type_parabola)
    {
        fe = FrequencyEstimatorSimple::create(FrequencyEstimatorSimple::Parabola); 
    }
    else if (config.freqest_type == config.freqest_type_lorentzian)
    {
        fe = FrequencyEstimatorSimple::create(FrequencyEstimatorSimple::Lorentzian); 
    }
    else
    {
        throw runtime_error("Unknown frequency estimator type.");
    }

    if (!fe.get())
        throw runtime_error("Error instantiating frequency estimator.");

    // fill in metadata

    scanOut.scanNumber = scanIn.scanNumber; 
    scanOut.retentionTime = scanIn.retentionTime;
    scanOut.observationDuration = scanIn.observationDuration;
    scanOut.calibrationParameters = scanIn.calibrationParameters;
    scanOut.peakFamilies.clear();

    // run the estimator on each envelope in the scan

    cerr << "Running " << config.freqest_type << " frequency estimator..." << flush;
    transform(scanIn.peakFamilies.begin(), scanIn.peakFamilies.end(),
              back_inserter(scanOut.peakFamilies), EnvelopeEstimator(*fe, fd));
    cerr << "done.\n";

    report.precision(12);
    report << scanOut << endl;
    
    return 0;
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:51,代码来源:proctran.cpp

示例6: dumpBody

   void CNavGGTO::dumpBody(ostream& s) const
      throw( InvalidRequest )
   {
      if (!dataLoaded())
      {
         InvalidRequest exc("Required data not stored.");
         GPSTK_THROW(exc);
      }
    
      s << endl
        << "           GPS/GNSS TIME OFFSET PARAMETERS"
        << endl
        << "Parameter        Value" << endl;

      s.setf(ios::fixed, ios::floatfield);
      s.setf(ios::right, ios::adjustfield);
      s.setf(ios::uppercase);
      s.precision(0);
      s.fill(' ');

      s << "GNSS_ID:          " << GNSS_ID; 
      if (GNSS_ID==NO_DATA_AVAIL) 
      { 
         s << ", NO DATA AVAILABLE" << endl;
         return;
      }
      else if (GNSS_ID==GALILEO_ID) s << ", Galileo";
      else if (GNSS_ID==GLONASS_ID) s << ", GLONASS";
      else s << ", other GNSS";
      s << endl;        

      s.setf(ios::scientific, ios::floatfield);
      s.precision(8);
      s << "A(0GGTO):         " << A0GGTO << " sec" <<endl;
      s << "A(1GGTO):         " << A1GGTO << " sec/sec" << endl;
      s << "A(2GGTO):         " << A2GGTO << " sec/sec**2" << endl;
      
   } // end of dumpBody()   
开发者ID:REC-SPb-ETU,项目名称:GPSTk,代码行数:38,代码来源:CNavGGTO.cpp

示例7: detect

int detect(const FrequencyData& fd, peakdata::Scan& scan, const Configuration& config, 
           ostream& report, ostream* log = 0)
{
    cerr << "Running peak detector..." << flush;
    auto_ptr<PeakDetector> pd = createPeakDetector(config, log);
    pd->findPeaks(fd, scan);
    cerr << "done.\n";
    cerr << "Peaks found: " << scan.peakFamilies.size() << endl;

    report.precision(12);
    report << scan << endl;

    return 0;
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:14,代码来源:proctran.cpp

示例8: Write

/**************************************************************************
Task: Linear equation::Write
Programing:
11/2007 WW/
**************************************************************************/
void Linear_EQS::Write(ostream &os)
{
   long i, size_A;
   A->Write(os);
   size_A = A->Dim();

   //
   os<<" b ( RHS): " <<endl;
   os.width(14);
   os.precision(8);
   //
   for(i=0; i<size_A; i++)
      os<<setw(10)<<i<<" "<<setw(15)<<b[i]<<endl;
}
开发者ID:wenqing,项目名称:ogs-FDM-PETSc,代码行数:19,代码来源:LinearEQS.cpp

示例9: print

void SparseGenome::print(ostream &sout) {
  static const int cutoff = 10;			// max loci to print
  int i;

  sout.setf(ios::fixed, ios::floatfield);
  sout.precision(4);

  sout << "sparse genome @ " << (void *)this << " w = " << w << endl << endl;
  for (i=0; i<nchromosomes; i++) {
    sout << "sa[" << i << "]: ";
    sa[i].print(sout,cutoff);
    sout << endl;
  }
}
开发者ID:douglasgscofield,项目名称:GeneticSimLib,代码行数:14,代码来源:sparsegenome.C

示例10: write_groups

void Radiation::write_groups(ostream& os)
{
  os << "# total number of groups = " << nGroups << endl;
  if (nNeutrinoSpecies > 0) {
    os << "# " << nNeutrinoSpecies
       << " neutrino species, numbers of groups are: ";
    for (int n = 0; n < nNeutrinoSpecies; n++) {
      if (n > 0) {
        os << ", ";
      }
      os << nNeutrinoGroups[n];
    }
    os << endl;
  }

  if (nGroups > 1) {
    os << "# group center, group weight" << group_units << endl;
    int oldprec = os.precision(10);
    for (int i = 0; i < nGroups; i++) {
      os.width(3);
      os << i << ": ";
      os.width(15);
      os <<  nugroup[i] * group_print_factor << ", ";
      os.width(15);
      os << dnugroup[i] * group_print_factor << endl;
    }
    os.precision(oldprec);
  }

  if (xnu.size() > 0) {
    os << "# group lower boundaries" << endl;
    for (int i = 0; i < xnu.size(); i++) {
      os << "group(" << i << ") = "
	 << xnu[i] * group_print_factor << endl;
    }
  }
}
开发者ID:zwghit,项目名称:CastroRadiation,代码行数:37,代码来源:RadMultiGroup.cpp

示例11: file_it

void file_it(ostream & os, double fo, const double fe[], int n){
    //参数os(其类型为ostream &)可以指向ostream对象(如cout), 也可以指向ofstream对象(如fout)。
    ios_base::fmtflags initial; //setf返回调用它之前有效的所有格式化设置。ios_base::fmtflags 是存储这种信息所需的数据类型名称
                                //因此,将返回值赋给initial将存储调用file_it()之前的格式化设置,然后便可以使用变量initial作为
                                //参数来调用setf,将所有的格式化设置恢复到原来的值。
    
    //方法setf使得能够设置各种格式化状态
    initial = os.setf(ios_base::fixed); //将对象置于使用定点表示法的模式
    os.precision(0);    //方法percision指定显示多少位小数(假定对象处于定点模式下)
    os << "Focal length of objective: " << fo << " mm\n";
    os.setf(ios::showpoint);    //将对象置于显示小数点的模式,即使小数点部分为零
    os.precision(1);
    os.width(12);   //方法width设置下一次输出操作使用的字段宽度,该设置只在显示下一个值时有效,过后恢复默认(0)
    os << "f.l. eyepiece";
    os.width(15);
    os << "magnification" << endl;
    for(int i = 0; i < n; ++i){
        os.width(12);
        os << fe[i];
        os.width(15);
        os << int (fo/fe[i] + 0.5) << endl;
    }
    os.setf(initial);
}
开发者ID:Phvnux,项目名称:cpplearning,代码行数:24,代码来源:filefunc.cpp

示例12: DumpTags

void CPicture::DumpTags( ostream& os, bool bRaw /*=false*/ ) {
	CTagMap::const_iterator i;
	int	idx = os.xalloc();
	for( i = TAGMAP.begin(); i != TAGMAP.end(); ++i ) {
		os << (*i).second;
		if( (*i).first > 30000 ) {
			if( PICT_DATA_PSHORT == (*i).second.Type() ) {
				LPWORD	pWord = (LPWORD) (*i).second.pVal();
				if( !bRaw )
					os << endl << szT1;
				for( int ii = 0; ii < (*i).second.Count(); ii++ ) {
					if( !bRaw && ii > 0 && ii % 4 == 0 )
						os << endl;
					if( ii > 0 )
						os << szT1;
					os << pWord[ii];
				}
			} else if( PICT_DATA_PDOUBLE == (*i).second.Type() ) {
				if( !bRaw )
					os << endl << szT1;
				int f = os.flags();
				os.flags( f | ios::fixed );
				os.precision( 5 );
				double	*pDbl = (double*) (*i).second.pVal();
				for( int ii = 0; ii < (*i).second.Count(); ii++ ) {
					if( !bRaw && ii > 0 && ii % 6 == 0 )
						os << endl;
					if( ii > 0 )
						os << szT1;
					os << pDbl[ii];
				}
				os.flags(f);
			} else if( PICT_DATA_PLONG == (*i).second.Type() ) {
				if( !bRaw )
					os << endl << szT1;
				long	*pLng = (long*) (*i).second.pVal();
				for( int ii = 0; ii < (*i).second.Count(); ii++ ) {
					if( !bRaw && ii > 0 && ii % 6 == 0 )
						os << endl;
					if( ii > 0 )
						os << szT1;
					os << pLng[ii];
				}
			}
		}
		os << endl;
	}
}
开发者ID:hkaiser,项目名称:TRiAS,代码行数:48,代码来源:TagMgr.cpp

示例13:

void 
Rule::
print(ostream& os)
{
	stringstream ss;
	ss<<prob;
	string temp;
	ss>>temp;
	//os.setf(
	os.precision(5);
	os.setf(ios::fixed,ios::floatfield);
	os<<prob<<"   ";
	//if(temp.length()<8)
	//	os<<"\t";
	os<<left<<" --> "<<right<<endl;
}
开发者ID:lixiangnlp,项目名称:egret,代码行数:16,代码来源:Rule.cpp

示例14: print

void numMatrix::print(ostream &out){
	for(int i=0; i<_n_rows; i++){
		out << "Row " << i << endl;
		for(int j=0; j<_n_cols; j++){
			out.setf(ios::scientific);
			out.precision(4);
			out.width(13);
			out << _coeff[i][j];
			if((j+1)%6 == 0){
				out << endl;
			}
		}
		out << endl;	
		out << endl;	
	}
}
开发者ID:sbolding,项目名称:holo,代码行数:16,代码来源:numMatrix.cpp

示例15: pattern

void
LinetreePrinter::printInf( ostream& inf,
                                                   const Vector3& _max ,
                                                   const Vector3& _min ) const{

        inf << "File : 1geom" << std::endl;
    inf << "Age : 5   1  pattern(s) number of branches 1"  << std::endl;
    inf << "Random_seed 0 Simplification 0 " << std::endl;

    inf.precision(6);

    inf << _max.x() << " " << _max.y() << " " << _max.z() << std::endl;
    inf << _min.x() << " " << _min.y() << " " << _min.z() << std::endl;
    inf << "entre-noeud 1        nentn105  1" << endl;

}
开发者ID:kkremitzki,项目名称:plantgl,代码行数:16,代码来源:linetreeprinter.cpp


注:本文中的ostream::precision方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。