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


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

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


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

示例1: doWriteBrushFace

 void doWriteBrushFace(std::ostream& stream, Model::BrushFace* face) {
     const String& textureName = face->textureName().empty() ? Model::BrushFace::NoTextureName : face->textureName();
     const Model::BrushFace::Points& points = face->points();
     
     stream.precision(FloatPrecision);
     stream <<
     "( " <<
     points[0].x() << " " <<
     points[0].y() << " " <<
     points[0].z() <<
     " ) ( "           <<
     points[1].x() << " " <<
     points[1].y() << " " <<
     points[1].z() <<
     " ) ( "           <<
     points[2].x() << " " <<
     points[2].y() << " " <<
     points[2].z() <<
     " ) ";
     
     stream.precision(6);
     stream <<
     textureName             << " " <<
     face->xOffset()          << " " <<
     face->yOffset()          << " " <<
     face->rotation()         << " " <<
     face->xScale()           << " " <<
     face->yScale()           << "\n";
 }
开发者ID:Gustavo6046,项目名称:TrenchBroom,代码行数:29,代码来源:MapStreamSerializer.cpp

示例2: write

//===========================================================================
void Torus::write(std::ostream& os) const
//===========================================================================
{
    // Note on the data format: See comments for read().

    streamsize prev = os.precision(15);
    os << dimension() << endl
       << major_radius_ << endl
       << minor_radius_ << endl
       << location_ << endl
       << z_axis_ << endl
       << x_axis_ << endl;
    if (select_outer_)
	os << "1" << endl;
    else
	os << "0" << endl;

    // NB: Mind the parameter sequence!
    os << parbound_.umin() << " " << parbound_.umax() << endl
       << parbound_.vmin() << " " << parbound_.vmax() << endl;

    if (!isSwapped()) {
        os << "10" << endl;
    }
    else {
        os << "11" << endl;
    }
    os << domain_.umin() << " " << domain_.umax() << endl
       << domain_.vmin() << " " << domain_.vmax() << endl;

    os.precision(prev);   // Reset precision to it's previous value
}
开发者ID:SINTEF-Geometry,项目名称:GoTools,代码行数:33,代码来源:Torus.C

示例3: writeFace

        void MapWriter::writeFace(const Model::Face& face, std::ostream& stream) {
            const String textureName = Utility::isBlank(face.textureName()) ? Model::Texture::Empty : face.textureName();
            
            stream.precision(FloatPrecision);
            stream <<
            "( " <<
            face.point(0).x() << " " <<
            face.point(0).y() << " " <<
            face.point(0).z() <<
            " ) ( "           <<
            face.point(1).x() << " " <<
            face.point(1).y() << " " <<
            face.point(1).z() <<
            " ) ( "           <<
            face.point(2).x() << " " <<
            face.point(2).y() << " " <<
            face.point(2).z() <<
            " ) ";

            stream.precision(6);
            stream <<
            textureName     << " " <<
            face.xOffset()  << " " <<
            face.yOffset()  << " " <<
            face.rotation() << " " <<
            face.xScale()   << " " <<
            face.yScale()   << "\n";
        }
开发者ID:ProPuke,项目名称:TrenchBroom,代码行数:28,代码来源:MapWriter.cpp

示例4:

/////////////WRITE////////////////////////////////////////
//
void
SpatialConstraint::write(std::ostream &out) const {
  size_t p = out.precision();
  out.precision(16);
  out << a_ << ' ' << d_ << "\n";
  out.precision(p);
}
开发者ID:d80b2t,项目名称:python,代码行数:9,代码来源:SpatialConstraint.cpp

示例5: Write

//-----------------------------------------------------------------------------
bool ConicModel::Write(std::ostream& out) const
{
    int prec = out.precision(3);						// Sauvegarde des parametres du flux
    std::ios::fmtflags flags = out.setf(std::ios::fixed);

    out << "  <intrinseque>" << std::endl;

    out << "   <sensor>" << std::endl;
    out << "    <image_size> " << std::endl;
    out << "     <width> " <<  m_width << " </width>" << std::endl;
    out << "     <height> " <<  m_height << " </height>" << std::endl;
    out << "    </image_size>" << std::endl;

    out.precision(3);

    out << "    <ppa>" << std::endl;
    out << "     <c> " <<  m_cPPA << " </c>" << std::endl;
    out << "     <l> " <<  m_lPPA  << " </l>" << std::endl;
    out << "     <focale> " <<  m_focal << " </focale>" << std::endl;
    out << "    </ppa>" << std::endl;

    if(m_distortion) m_distortion->Write(out);

    out << "   </sensor>" << std::endl;

    out << "  </intrinseque>" << std::endl;

    out.precision(prec);		// Restauration des parametres du flux
    out.unsetf(std::ios::fixed);
    out.setf(flags);

    return out.good();
}
开发者ID:IGNF,项目名称:libOri,代码行数:34,代码来源:ConicModel.cpp

示例6: sumlines

void sumlines(std::istream &in, std::ostream &out) {
	boost::io::ios_all_saver io_all(out);
	std::string line;
	out.setf(std::ios::fixed, std::ios::floatfield);
	boost::regex re_float("-?\\d+([.]\\d{2})?");
	while (std::getline(in, line)) {
		try {
			double sum = 0.0;
			std::istringstream iss(line);
			std::string item;
			while (iss >> item) {
				if (!boost::regex_match(item, re_float))
					throw nullptr;
				sum += std::stod(item);
			}
			if (static_cast<long long>(sum) == sum)
				out.precision(0);
			else
				out.precision(2);
			out << sum << '\n';
		}
		catch (std::nullptr_t) {
			out << "EFMT: " << line << '\n';
		}
	}
}
开发者ID:tbfe-de,项目名称:mc-cpp11-BLWS,代码行数:26,代码来源:step3c.cpp

示例7: writePosition

void BinaryFormatter::writePosition(std::ostream& into, const Position& val) {
    if (val.z() != 0.) {
        if (into.precision() == 2 && val.x() < 2e7 && val.x() > -2e7 &&
                val.y() < 2e7 && val.y() > -2e7 && val.z() < 2e7 && val.z() > -2e7) { // 2e7 is roughly INT_MAX/100
            FileHelpers::writeByte(into, BF_SCALED2INT_POSITION_3D);
            FileHelpers::writeInt(into, int(val.x() * 100. + .5));
            FileHelpers::writeInt(into, int(val.y() * 100. + .5));
            FileHelpers::writeInt(into, int(val.z() * 100. + .5));
        } else {
            FileHelpers::writeByte(into, BF_POSITION_3D);
            FileHelpers::writeFloat(into, val.x());
            FileHelpers::writeFloat(into, val.y());
            FileHelpers::writeFloat(into, val.z());
        }
    } else {
        if (into.precision() == 2 && val.x() < 2e7 && val.x() > -2e7 &&
                val.y() < 2e7 && val.y() > -2e7) { // 2e7 is roughly INT_MAX/100
            FileHelpers::writeByte(into, BF_SCALED2INT_POSITION_2D);
            FileHelpers::writeInt(into, int(val.x() * 100. + .5));
            FileHelpers::writeInt(into, int(val.y() * 100. + .5));
        } else {
            FileHelpers::writeByte(into, BF_POSITION_2D);
            FileHelpers::writeFloat(into, val.x());
            FileHelpers::writeFloat(into, val.y());
        }
    }
}
开发者ID:fieryzig,项目名称:sumo,代码行数:27,代码来源:BinaryFormatter.cpp

示例8: report_list

void report_list(
    std::ostream& o,
    const Vector& list,
    const char* prefix = "  "
) {
    if (!list.empty()) {
        typename Vector::value_type min_value, max_value;
        min_value = *std::min_element(list.begin(), list.end());
        max_value = *std::max_element(list.begin(), list.end());
        if (min_value == max_value) {
            o << prefix << "\t" << min_value << "\n";
        } else {
            o << std::endl;
            o << prefix << "min:\t" << min_value << "\n";
            o << prefix << "median:\t" << median_element(list) << "\n";
            std::streamsize precision = o.precision();
            o.setf(std::ios::fixed, std::ios_base::floatfield);
            o.precision(2);
            o << prefix << "avg:\t" << avg_element_double(list) << "\n";
            o.precision(precision);
            o.unsetf(std::ios_base::floatfield);
            o << prefix << "max:\t" << max_value << "\n";
        }
    }
    o << std::endl;
}
开发者ID:npge,项目名称:npge,代码行数:26,代码来源:report_list.hpp

示例9: writeRawLaser

void CarmenLogWriter::writeRawLaser(std::ostream& _stream, const LaserReading* _reading) const{
    _stream << std::fixed;
    _stream << _reading->getName() << " " << "0 ";
    
    const std::vector<double>& rho = _reading->getRho();
    const std::vector<double>& phi = _reading->getPhi();

    _stream.precision(6);
    _stream << phi.front() << " " << phi.back() - phi.front() << " " << (phi[1] - phi[0]) << " " << _reading->getMaxRange() << " " << "0.010000 "<< "0 ";
    
    _stream << rho.size() << " ";
    
    _stream.precision(3);
    for(uint i = 0; i < rho.size(); i++){
	_stream << rho[i] << " ";
    }
    
    const std::vector<double>& remission = _reading->getRemission();
    _stream << remission.size() << " ";
    
    for(uint i = 0; i < remission.size(); i++){
	_stream << remission[i] << " ";
    }
        
    _stream << _reading->getTime() << " " << _reading->getRobot() << " " << _reading->getTime() << std::endl;
}
开发者ID:ros-gbp,项目名称:flirtlib-release,代码行数:26,代码来源:CarmenLog.cpp

示例10: writeSpeciesData

    void writeSpeciesData(std::ostream& log, const Species& spec) {
        
        if (!spec.id.empty()) 
            log << endl << "   id/date: " << spec.id << endl;
        else 
            log << " ... " << endl;
        
        log << "   phase: " 
            << spec.phase << endl 
            << "   composition: (";
        
        for (size_t ie = 0; ie < spec.elements.size(); ie++) {
	  if (!spec.elements[ie].name.empty()) {
	    log.flags(ios::fixed);
	    log.precision(0);
	    if (ie > 0) log << ", ";
	    log << spec.elements[ie].number << " " 
		<< spec.elements[ie].name;
	  }
        } 
        log << ")";
	
	if (spec.thermoFormatType == 0) {
	  log.flags(ios::showpoint | ios::fixed);
	  log.precision(2);
	  log << endl << "   Tlow, Tmid, Thigh: (" << spec.tlow << ", " << 
            spec.tmid << ", " << spec.thigh << ")" << endl << endl;
	  log << "   coefficients (low, high):" << endl;
	  log.flags(ios::scientific | ios::uppercase | ios::internal );
	 log.precision(8);
	 for (int j = 0; j < 7; j++) { 
	   log << "   a" << j + 1;
	   log.setf(ios::showpos);
	   log << "  \t" << spec.lowCoeffs[j] 
	       << "  \t" << spec.highCoeffs[j] << endl;
	   log.unsetf(ios::showpos);
	 }
	 log << endl;
	} else if (spec.thermoFormatType == 1) {
	  log.flags(ios::showpoint | ios::fixed);
	  log.precision(2);
	  log << endl;
	  log << "Number of temp regions = " << spec.nTempRegions << endl;
	  for (int i = 0; i < spec.nTempRegions; i++) {
	    log << "   Tlow, Thigh: (" << spec.minTemps[i] << ", " 
		<< spec.maxTemps[i] << ")" << endl << endl;
	    log << "   coefficients :" << endl;
	    log.flags( ios::scientific | ios::uppercase | ios::internal);
            log.precision(8);
	    vector_fp &cc = *spec.region_coeffs[i];
	    for (int j = 0; j < 9; j++) { 
	      log << "   a" << j + 1;
	      log.setf(ios::showpos);
	      log << "  \t" << cc[j]  << endl;
	      log.unsetf(ios::showpos);
	    }
	    log << endl;
	  }
        }
     }
开发者ID:hkmoffat,项目名称:cantera,代码行数:60,代码来源:writelog.cpp

示例11: writeResults

void MpiWrapper::writeResults(std::ostream& strm) const {
    
    if( myRank != 0 || !data ) return;
    
    streamsize oldPrec = strm.precision(8);
    
    strm << "# (partially) corrected Zernikes: " << efficiencies.size() << "   efficiencies=[";
    for(unsigned int i=0; i<efficiencies.size(); ++i) { strm << (i?", ":" ") << freq[i]; }
    strm << "]\n# spatial frequency\n";
    for(unsigned int i=0; i<freq.size(); ++i) strm << freq[i] << endl;
    strm << "# seeing alpha\n";
    for(unsigned int i=0; i<alpha.size(); ++i) strm << alpha[i] << endl;
    strm << "# functions\n";
    double* ptr = data.get();
    double sr, sr_sigma;

    for( unsigned int i = 0; i < alpha.size(); ++i ) {
        strm << "letf           s_letf         stf            s_stf          sr             s_sr\n";
        for( unsigned int j = 0; j < freq.size(); ++j ) {
            if(ptr[0] > 0 && ptr[2] && finite(ptr[1]) && finite(ptr[3]) ) {
                sr = ptr[0]*ptr[0]/ptr[2];
                sr_sigma = sr*sqrt(ptr[1] * ptr[1] / (ptr[0] * ptr[0]) + ptr[3] * ptr[3] / (ptr[2] * ptr[2]));
            } else sr = sr_sigma = 0;
            strm << setw(15) << left << ptr[0];             // LTF
            strm << setw(15) << left << ptr[1];             // LTF sigma
            strm << setw(15) << left << ptr[2];             // STF
            strm << setw(15) << left << ptr[3];             // STF sigma
            strm << setw(15) << left << sr;                 // Spectral ratio
            strm << setw(15) << left << sr_sigma << endl;     // Spectral ratio sigma
            ptr += 4;
        }
    }
    strm.precision(oldPrec);

}
开发者ID:ISP-SST,项目名称:redux,代码行数:35,代码来源:mpiwrapper.cpp

示例12:

void
GslVector::print(std::ostream& os) const
{
  //std::cout << "In GslVector::print(): before sizelocal()"
  //          << std::endl;
  unsigned int size = this->sizeLocal();
  //std::cout << "In GslVector::print(): after sizelocal()"
  //          << std::endl;

  //std::cout << "In GslVector::print(): before os.flags()"
  //          << std::endl;
  std::ostream::fmtflags curr_fmt = os.flags();
  //std::cout << "In GslVector::print(): after os.flags()"
  //          << std::endl;

  if (m_printScientific) {
    unsigned int savedPrecision = os.precision();
    os.precision(16);

    if (m_printHorizontally) {
      for (unsigned int i = 0; i < size; ++i) {
        os << std::scientific << (*this)[i]
           << " ";
      }
    }
    else {
      for (unsigned int i = 0; i < size; ++i) {
        os << std::scientific << (*this)[i]
           << std::endl;
      }
    }

    os.precision(savedPrecision);
  }
  else {
    if (m_printHorizontally) {
      //std::cout << "In GslVector::print(): where expected"
      //          << std::endl;
      for (unsigned int i = 0; i < size; ++i) {
        os << std::dec << (*this)[i]
           << " ";
      }
    }
    else {
      for (unsigned int i = 0; i < size; ++i) {
        os << std::dec << (*this)[i]
           << std::endl;
      }
    }
  }

  //std::cout << "In GslVector::print(): before os.flags(curr_fmt)"
  //          << std::endl;
  os.flags(curr_fmt);
  //std::cout << "In GslVector::print(): after os.flags(curr_fmt)"
  //          << std::endl;

  return;
}
开发者ID:roystgnr,项目名称:queso,代码行数:59,代码来源:GslVector.C

示例13: OutputMaterials

void OutputMaterials(std::ostream &ofs, SModel* model)
{
	ofs << "METERIALS" << std::endl;
	ofs << "NumMaterials= " << model->numMaterials << std::endl;

	if ( model->numMaterials == 0 )
	{
		model->materials = NULL;
		return;
	}

	for ( uint i = 0; i < model->numMaterials; i++ )
	{
		SMaterial* mat = &model->materials[ i ];
		ofs << "\t" << "MaterialType= " << mat->type << std::endl;
		ofs << "\t" << SMatNames[mat->type] << " " << mat->name << "\n";
		ofs << "\t\t" << "materialID= " << mat->materialID << std::endl;

		// set float format
		std::streamsize oldPrec = ofs.precision(5);
		ofs.setf(std::ios::fixed,std::ios::floatfield);	// floatfield set to fixed

		OutputAttribute(ofs, "ambient       ", mat->ambient);
		OutputAttribute(ofs, "diffuse       ", mat->diffuse);
		OutputAttribute(ofs, "incandescence ", mat->incandescence);
		OutputAttribute(ofs, "transparency  ", mat->transparency);

		ofs << "\t\t" << "normalmap      tex= " << mat->normalmapTex << "\n";

		switch(mat->type) 
		{
			case MATERIAL_PHONG:
				{
					OutputAttribute(ofs, "specular      ", mat->specular);
					ofs	<< "\t\t" << "shininess      " << mat->shininess << std::endl; 
				}
				break;
			case MATERIAL_BLINN:
				{
					OutputAttribute(ofs, "specular      ", mat->specular);
					ofs	<< "\t\t" << "eccentricity   " << mat->eccentricity << std::endl; 
					ofs	<< "\t\t" << "specularRollOff " << mat->specularRollOff << std::endl; 
				}
				break;
			case MATERIAL_LAMBERT:
				{
					// nothing
				}
				break;
			default:
				assert(0); exit(1);
		}
	
		// unset float format
		ofs.precision(oldPrec);
		ofs.unsetf(std::ios::floatfield);
	}
}
开发者ID:shikui08,项目名称:character-system,代码行数:58,代码来源:Material.cpp

示例14: write

void YAPCAReduce<eltype>::save_map(std::ostream &out) const {
  ya_sizet precision=out.precision();
  out.precision(16);
  this->write_header(out);
  write(out,eigen_vectors);
  write(out,this->eigen_values);
  write(out,column_means);
  out.precision(precision);
}
开发者ID:e-thereal,项目名称:gapputils,代码行数:9,代码来源:ya_pca_reduce.cpp

示例15: writeXml

void Double::writeXml(std::ostream& out) const
{
    std::streamsize old = out.precision();

    out << std::setprecision(std::numeric_limits < double >::digits10)
        << "<double>" << m_value << "</double>";

    out.precision(old);
}
开发者ID:alsabadel,项目名称:vle,代码行数:9,代码来源:Double.cpp


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